Module type Rpc_intf.Connection

module type Connection = sig .. end

module Server: sig .. end
type t 
val create : ?server:'s Server.t ->
connection_state:'s ->
?max_message_size:int ->
Import.Reader.t ->
Import.Writer.t ->
(t, Core.Std.Exn.t) Core.Std.Result.t Import.Deferred.t
Initiate an Rpc connection on the given reader/writer pair. server should be the bag of implementations that the calling side implements; it defaults to Server.null (i.e., "I implement no RPCs").
val close : t -> unit Import.Deferred.t
val close_finished : t -> unit Import.Deferred.t
val is_closed : t -> bool
val bytes_to_write : t -> int
val with_close : ?server:'s Server.t ->
connection_state:'s ->
Import.Reader.t ->
Import.Writer.t ->
dispatch_queries:(t -> 'a Import.Deferred.t) ->
on_handshake_error:[ `Call of Core.Std.Exn.t -> 'a Import.Deferred.t | `Raise ] ->
'a Import.Deferred.t
with_close tries to create a t using the given reader and writer. If a handshake error is the result, it calls on_handshake_error, for which the default behavior is to raise an exception. If no error results, dispatch_queries is called on t.

After dispatch_queries returns, if server is None, the t will be closed and the deferred returned by dispatch_queries wil be determined immediately. Otherwise, we'll wait until the other side closes the connection and then close t and determine the deferred returned by dispatch_queries.

When the deferred returned by with_close becomes determined, both Reader.close and Writer.close have finished.

val server_with_close : Import.Reader.t ->
Import.Writer.t ->
server:'s Server.t ->
connection_state:'s ->
on_handshake_error:[ `Call of Core.Std.Exn.t -> unit Import.Deferred.t
| `Ignore
| `Raise ] ->
unit Import.Deferred.t
val serve : server:'s Server.t ->
initial_connection_state:(([< Import.Socket.Address.t ] as 'a) -> 's) ->
where_to_listen:('a, 'listening_on) Tcp.Where_to_listen.t ->
?auth:('a -> bool) ->
?on_handshake_error:[ `Call of Core.Std.Exn.t -> unit | `Ignore | `Raise ] ->
unit -> ('a, 'listening_on) Tcp.Server.t Import.Deferred.t
serve server ~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.
val client : host:string ->
port:int ->
(t, Core.Std.Exn.t) Core.Std.Result.t Import.Deferred.t
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.
val with_client : host:string ->
port:int ->
(t -> 'a Import.Deferred.t) ->
('a, Core.Std.Exn.t) Core.Std.Result.t Import.Deferred.t
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.