module Server: sig
.. end
type
t
include Invariant.S
val create : ?logfun:Versioned_typed_tcp.S.logfun ->
?now:(unit -> Core.Std.Time.t) ->
?enforce_unique_remote_name:bool ->
?is_client_ip_authorized:(string -> bool) ->
?warn_when_free_connections_lte_pct:float ->
?max_clients:int ->
listen_port:int ->
My_name.t -> t Import.Deferred.t
create a new server, and start listening
val port : t -> int
get the port that the server is listening on
val close : t -> Remote_name.t -> unit
close t client
close connection to client
if it
exists. This does not prevent the same client from connecting
again later.
val listen : t ->
(Remote_name.t, Recv.t) Versioned_typed_tcp.Server_msg.t Import.Stream.t
listen t
listen to the stream of messages and errors coming from clients
val listen_ignore_errors : ?stop:unit Import.Deferred.t ->
t -> Recv.t Import.Stream.t
listen_ignore_errors t
like listen, but omit error conditions and
metadata. When listen_ignore_errors is called it installs a filter on
the stream that never goes away (unless t is destroyed, or you
provide a stop
).
val send : t ->
Remote_name.t ->
Send.t -> [ `Dropped | `Sent of Core.Std.Time.t ] Import.Deferred.t
send t client msg
send msg
to client
.
Returns a
deferred that will become determined when the message has been
sent. In the case of an error, the message will be dropped,
and the deferred will be filled with `Dropped
(meaning the
message was never handed to the OS), otherwise it will be
filled with with `Sent tm
where tm is the time (according to
Time.now) that the message was handed to the operating
system. It is possible that the deferred will never become
determined, for example in the case that the other side hangs,
but does not drop the connection.
val send_ignore_errors : t -> Remote_name.t -> Send.t -> unit
send_ignore_errors t client msg
Just like send, but does not report
results. Your message will probably be sent successfully
sometime after you call this function. If you receive a
Disconnect
error on the listen channel in close time
proximity to making this call then your message was likely
dropped.
val send_to_all : t ->
Send.t -> [ `Dropped | `Partial_success | `Sent ] Import.Deferred.t
send_to_all t msg
send the same message to all connected clients.
val send_to_all_ignore_errors : t -> Send.t -> unit
send_to_all_ignore_errors t msg
Just like send_to_all
but with no error
reporting.
val send_to_some : t ->
Send.t ->
Remote_name.t list ->
[ `Dropped | `Partial_success | `Sent ] Import.Deferred.t
send_to_some t msg names
send the same message to multiple connected clients.
val send_to_some_ignore_errors : t -> Send.t -> Remote_name.t list -> unit
send_to_some_ignore_errors t msg
Just like send_to_some
but with no error
reporting.
val client_send_version : t ->
Remote_name.t -> Versioned_typed_tcp.Version.t option
val flushed : t ->
cutoff:unit Import.Deferred.t ->
([ `Flushed of Remote_name.t list ] * [ `Not_flushed of Remote_name.t list ])
Import.Deferred.t
val shutdown : t -> unit Import.Deferred.t