These functions are mostly the same as the ones with the same names in
Async_rpc_kernel.Std.Rpc.Connection
; see Connection_intf
in that library for
documentation. The differences are that:
Async_unix.Std.Reader.t
, Async_unix.Std.Writer.t
and
max_message_size
instead of a Transport.t
Time
instead of Time_ns
A function creating a transport from a file descriptor. It is responsible for setting the low-level parameters of the underlying transport.
For instance to setup a transport using Async.Std.{Reader,Writer}
and set a buffer
age limit on the writer, you can pass this to the functions of this module:
~make_transport:(fun fd ~max_message_size ->
Rpc.Transport.of_fd fd ~max_message_size ~buffer_age_limit:`Unlimited)
serve implementations ~port ?on_handshake_error ()
starts a server with the given
implementation on port
. The optional auth function will be called on all incoming
connections with the address info of the client and will disconnect the client
immediately if it returns false. This auth mechanism is generic and does nothing
other than disconnect the client - any logging or record of the reasons is the
responsibility of the auth function itself.
client ~host ~port ()
connects to the server at (host
,port
) and returns the
connection or an Error if a connection could not be made. It is the responsibility
of the caller to eventually call close.
In client
and with_client
, the handshake_timeout
encompasses both the TCP
connection timeout and the timeout for this module's own handshake.
with_client ~host ~port f
connects to the server at (host
,port
) and runs f
until an exception is thrown or until the returned Deferred is fulfilled.
NOTE: As with with_close
, you should be careful when using this with Pipe_rpc
.
See with_close
for more information.