IO.TCP_serverA TCP server abstraction.
type conn_handler = {handle : client_addr:Unix.sockaddr -> Input.t -> Output.t -> unit;Handle client connection
*)}type t = {endpoint : unit -> string * int;Endpoint we listen on. This can only be called from within serve.
active_connections : unit -> int;Number of connections currently active
*)running : unit -> bool;Is the server currently running?
*)stop : unit -> unit;Ask the server to stop. This might not take effect immediately, and is idempotent. After this server.running() must return false.
}A running TCP server.
This contains some functions that provide information about the running server, including whether it's active (as opposed to stopped), a function to stop it, and statistics about the number of connections.
type builder = {serve : after_init:(t -> unit) -> handle:conn_handler -> unit -> unit;Blocking call to listen for incoming connections and handle them. Uses the connection handler handle to handle individual client connections in individual threads/fibers/tasks.
}A TCP server builder implementation.
Calling builder.serve ~after_init ~handle () starts a new TCP server on an unspecified endpoint (most likely coming from the function returning this builder) and returns the running server.