module Client: sig
.. end
type
t
val create : ?logfun:Versioned_typed_tcp.S.logfun ->
?now:(unit -> Core.Std.Time.t) ->
?check_remote_name:bool ->
ip:string ->
port:int ->
expected_remote_name:Remote_name.t ->
My_name.t -> t Import.Deferred.t
create a new (initially disconnected) client
val connect : t -> unit Import.Deferred.t
connect t
If the connection is not currently established, initiate one.
Returns a deferred that becomes determined when the connection is established.
val close_connection : t -> unit
If a connection is currently established, close it. Also, if we're trying to
connect, give up.
val listen : t ->
(Remote_name.t, Recv.t) Versioned_typed_tcp.Client_msg.t Import.Stream.t
listen t
Returns a stream of messages from the server and errors
val listen_ignore_errors : ?stop:unit Import.Deferred.t ->
t -> Recv.t Import.Stream.t
listen_ignore_errors t
like listen
, but with no errors or meta data. 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), so you should
not call it many times throwing away the result. If you need to do this
use listen.
val send : t ->
Send.t -> [ `Dropped | `Sent of Core.Std.Time.t ] Import.Deferred.t
send t msg
send a message to the server. If the connection is
not currently established, initiate one.
Returns a deferred that is filled in with either the time the
message was handed to the OS, or `Dropped
. `Dropped
means that
there was an error, and the message will not be sent.
val send_ignore_errors : t -> Send.t -> unit
send_ignore_errors t
exactly like send
but with no error reporting.
val state : t ->
[ `Connected | `Connecting | `Disconnected ]
state t
Returns the state of the connection
val last_connect_error : t -> exn option
last_connect_error t
returns the error (if any) that happened on the
last connection attempt.
val flushed : t ->
[ `Flushed | `Pending of Core.Std.Time.t Import.Deferred.t ]