Module Net.Endpoint

Network endpoints.

See also Os.Socket.

type t = [
  1. | `Host of string * int
    (*

    Hostname and port.

    *)
  2. | `Sockaddr of Unix.sockaddr
    (*

    Given socket address.

    *)
  3. | `Fd of Unix.file_descr
    (*

    Direct file descriptor.

    *)
]

The type for specifying a socket endpoint to connect or to listen to on.

val of_string : default_port:int -> string -> (t, string) Stdlib.result

of_string ~default_port s parses a socket endpoint specification from s.

The format is ADDR[:PORT] or PATH for a Unix domain socket (detected by the the presence of a directory separator). default_port port is used if no PORT is specified.

val with_port_of_sockaddr : Unix.sockaddr -> t -> t

with_port_of_sockaddr saddr ep makes ep's port coincide with the port of saddr iff both have a port. Otherwise this is ep itself. This is mostly useful to adjust an endpoint whose port number was specified as 0 in order to get one allocated by bind.

val pp : Stdlib.Format.formatter -> t -> unit

pp formats endpoints.