Module NetTcp.Server

module Server: sig .. end

type receive_ev 
val reply : receive_ev -> Bencode.t -> unit
Reply to the event by sending a message
val msg : receive_ev -> Bencode.t
Message contained in the receive_ev
val addr : receive_ev -> NetTcp.Address.t
Address of the sender
type event = 
| Receive of receive_ev
| Stop
type t 
A server interface, that listens on some port on the network
val events : t -> event Signal.t
Signal transmitting events that occur on the server, when the server stops or a message is received
val create : ?retry:int -> ?port:int -> ?log:bool -> unit -> t option
Create a new network node on the given port, if provided (a random port otherwise). May return None if it is impossible to create a socket on the given port.
retry : number of times a random port is tried if the previous one is occypied (default 3)
val port : t -> int
Port used by the network server
val stop : t -> unit
Stop this server. It cannot be used anymore afterward.
val wait : t -> unit Lwt.t
Wait for the server to stop