package async_unix

  1. Overview
  2. Docs
Module type
Class type

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 =
  1. | Shutdown_socket
  2. | Do_not_shutdown_socket
type file_descriptor_handling =
  1. | Close_file_descriptor of socket_handling
  2. | Do_not_close_file_descriptor
val close : ?file_descriptor_handling:file_descriptor_handling -> t -> unit Async_kernel.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.


Innovation. Community. Security.