Module Net

Networking.

Warning. This interface is expected to move back to the more library, it will no longer be distributed by this library in the future.

Endpoints

module Endpoint : sig ... end

Network endpoints.

Connections

module Connection : sig ... end

Network connections.

val with_connection : ?nonblock:bool -> ?socket_type:Unix.socket_type -> peer:Endpoint.t -> (Connection.t -> 'a) -> ('a, string) Stdlib.result

with_connection ~peer f open a connection to peer, invokes f with the connection and makes sure it is properly closed when f returns with a value or an exception. See Connection.open' for details about the arguments.

val try_with_connection : ?nonblock:bool -> ?socket_type:Unix.socket_type -> peer:Endpoint.t -> (Connection.t -> 'a) -> ('a option, string) Stdlib.result

try_with_connection is like with_connection but uses Connection.try_open to open the connection.

val with_connection_close : Connection.t -> (Connection.t -> 'a) -> 'a

with_connection_close c f invokes with c and makes sure it is properly closed when f returns with a value or an exception.

Listeners

module Listener : sig ... end

Network connection listeners.

val with_listener : ?nonblock:bool -> ?socket_type:Unix.socket_type -> ?backlog:int -> on:Endpoint.t -> (Listener.t -> 'a) -> ('a, string) Stdlib.result

with_listener ~on f opens a listener on endpoint on, invokes f with the listener and makes sure it is properly closed when f returns with a value or an exception. See Listener.open' for details about the arguments.

Messaging

module Msg : sig ... end

Send and receive messages over stream sockets.

Formatters

val pp_sockaddr : Stdlib.Format.formatter -> Unix.sockaddr -> unit

pp_sock_addr formats socket addresses for inspection.

val pp_socket_type : Stdlib.Format.formatter -> Unix.socket_type -> unit

pp_socket_type formats socket types for inspection.