package riot

  1. Overview
  2. Docs
type 'kind socket = Fd.t
type listen_socket = [ `listen ] socket
type stream_socket = [ `stream ] socket
type listen_opts = {
  1. reuse_addr : bool;
  2. reuse_port : bool;
  3. backlog : int;
  4. addr : Addr.tcp_addr;
}
type timeout =
  1. | Infinity
  2. | Bounded of float
val listen : ?opts:listen_opts -> port:int -> unit -> (listen_socket, [> `System_limit ]) IO.result
val connect : Addr.stream_addr -> (stream_socket, [> `Closed ]) IO.result
val accept : ?timeout:timeout -> listen_socket -> (stream_socket * Addr.stream_addr, [> `Closed | `Timeout | `System_limit ]) IO.result
val close : _ socket -> unit
val controlling_process : _ socket -> new_owner:Pid.t -> (unit, [> `Closed | `Not_owner ]) IO.result
val receive : ?timeout:timeout -> buf:IO.Buffer.t -> stream_socket -> (int, [> `Closed | `Timeout ]) IO.result
val send : data:IO.Buffer.t -> stream_socket -> (int, [> `Closed ]) IO.result
val pp : Stdlib.Format.formatter -> _ socket -> unit
val pp_err : Stdlib.Format.formatter -> [ IO.unix_error | `Closed | `Timeout | `System_limit ] -> unit
OCaml

Innovation. Community. Security.