The Close
module exists to collect close
and its associated types, so they
can be easily reused elsewhere, e.g. Unix_syscalls
.
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 Import.Deferred.t
close t
prevents further use of t
, and makes shutdown()
and close()
system
calls on t
's underlying file descriptor according to the
file_descriptor_handling
argument and whether or not t
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 call close
multiple times on the same t
; calls subsequent to the initial call
will have no effect, but will return the same deferred as the original call.