Net.MsgSend and receive messages over stream sockets.
Using simple length-value frames.
val send : Connection.t -> string -> (unit, string) Stdlib.resultsend c msg sends the bytes msg on c. The result is:
Ok () if the frame for msg was seemingly sent successfuly.Error e if the peer unexpectedly closed the connection or another error occurs. In this case you should proceed to Connection.close_noerr the connection.val send' : Connection.t -> string -> (unit, Unix.error) Stdlib.resultsend' is like send but you get the unix error status on error, in case you want to try to (unreliably) reason on the peer closure.
val wait_sendable : Connection.t -> 'tag -> 'tag Affect.Action.twait_sendable c tag is the action used by send. The action invocation is enabled and synchronizes with tag when a send can be initiated without blocking. However since multiple write(2) may be needed, the call can still block. This is just Affect_unix.Unix.wait_writable on the connection's file descriptor.
val recv : Connection.t -> (string option, string) Stdlib.resultrecv c receives a message from c. The result is:
Ok (Some msg) if msg was received in a frame.Ok None if the connection was closed gracefuly (0 bytes were read at the beginning of the frame).Error e is the peer unexpectedly closed the connection, if a frame is truncated or invalid, or if any other error occurs. In this case you should proceed to Connection.close_noerr the connection.val wait_recvable : Connection.t -> 'tag -> 'tag Affect.Action.twait_recvable c tag is the action used by recv. The action invocation is enabled and synchronizes with tag when a recv can be initiated without blocking. However since mulitple read(2) may be needed the call can still block. This is just Affect_unix.Unix.wait_readable on the connection's file descriptor.