Module Fd.Close
The Close
module exists to collect close
and its associated types, so they can be easily reused elsewhere, e.g., Unix_syscalls
.
type socket_handling
=
|
Shutdown_socket
|
Do_not_shutdown_socket
type file_descriptor_handling
=
|
Close_file_descriptor of socket_handling
|
Do_not_close_file_descriptor
val close : ?file_descriptor_handling:file_descriptor_handling -> t -> unit Async_unix__.Import.Deferred.t
close t
prevents further use oft
, and makesshutdown()
andclose()
system calls ont
's underlying file descriptor according to thefile_descriptor_handling
argument and whether or nott
is a socket, i.e.,kind t = Socket `Active
:| file_descriptor_handling | shutdown() | close() | |----------------------------------------------+------------+---------| | Do_not_close_file_descriptor | no | no | | Close_file_descriptor Shutdown_socket | if socket | yes | | Close_file_descriptor Do_not_shutdown_socket | no | yes |
The result of
close
becomes determined once the system calls complete. It is OK to callclose
multiple times on the samet
; calls subsequent to the initial call will have no effect, but will return the same deferred as the original call.