Module Socket

module Socket: Unix_syscalls.Socket

module Address: sig .. end
module Family: sig .. end
type ([< `Active | `Bound | `Passive | `Unconnected ]
, [< Address.t ])
t
Sockets have a phantom type parameter that tracks the state of the socket in order to eliminate certain errors in which socket functions are called in the wrong order. Initially, a socket is `Unconnected. As various socket functions are called, they return a socket with a new phantom state. Here is a chart of the allowed state transitions.

        Unconnected ---connect--> Active
        |
        | ---bind--> Bound ---listen--> Passive ---accept---> Active
     

module Type: sig .. end
val create : ([< Address.t ] as 'a) Type.t ->
([ `Unconnected ], 'a) t
val connect : ([ `Unconnected ], [< Address.t ] as 'a)
t ->
'a -> ([ `Active ], 'a) t Import.Deferred.t
val connect_interruptible : ([ `Unconnected ], [< Address.t ] as 'a)
t ->
'a ->
interrupt:unit Import.Deferred.t ->
[ `Interrupted | `Ok of ([ `Active ], 'a) t ]
Import.Deferred.t
val bind : ([ `Unconnected ], [< Address.t ] as 'a)
t ->
'a -> ([ `Bound ], 'a) t Import.Deferred.t
bind socket addr sets close_on_exec for the fd of socket.
val listen : ?max_pending_connections:int ->
([ `Bound ], [< Address.t ] as 'a)
t -> ([ `Passive ], 'a) t
val accept : ([ `Passive ], [< Address.t ] as 'a)
t ->
[ `Ok of ([ `Active ], 'a) t * 'a | `Socket_closed ]
Import.Deferred.t
val accept_interruptible : ([ `Passive ], [< Address.t ] as 'a)
t ->
interrupt:unit Import.Deferred.t ->
[ `Interrupted
| `Ok of ([ `Active ], 'a) t * 'a
| `Socket_closed ] Import.Deferred.t
val shutdown : ([< `Active | `Bound | `Passive | `Unconnected ],
[< Address.t ])
t -> [ `Both | `Receive | `Send ] -> unit
val fd : ([< `Active | `Bound | `Passive | `Unconnected ],
[< Address.t ])
t -> Fd.t
val of_fd : Fd.t ->
([< Address.t ] as 'a) Type.t ->
([< `Active | `Bound | `Passive | `Unconnected ], 'a) t
val getsockname : ([< `Active | `Bound | `Passive | `Unconnected ],
[< Address.t ] as 'a)
t -> 'a
val getpeername : ([< `Active | `Bound | `Passive | `Unconnected ],
[< Address.t ] as 'a)
t -> 'a
module Opt: sig .. end
val getopt : ([< `Active | `Bound | `Passive | `Unconnected ],
[< Address.t ])
t -> 'c Opt.t -> 'c
val setopt : ([< `Active | `Bound | `Passive | `Unconnected ],
[< Address.t ])
t -> 'c Opt.t -> 'c -> unit
val sexp_of_t : (([< `Active | `Bound | `Passive | `Unconnected ] as 'a) -> Sexplib.Sexp.t) ->
(([< Address.t ] as 'b) -> Sexplib.Sexp.t) ->
('a, 'b) t -> Sexplib.Sexp.t

bind socket addr sets close_on_exec for the fd of socket.