Mavryk_base_unix.Socket
val connect :
?timeout:Ptime.Span.t ->
addr ->
Lwt_unix.file_descr Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t
connect ?timeout addr
tries connecting to addr
and returns the resulting socket file descriptor on success. When using TCP, Unix.getaddrinfo
is used to resolve the hostname and service (port). The different socket addresses returned by Unix.getaddrinfo
are tried sequentially, and the ?timeout
argument (default: 5s) governs how long it waits to get a connection. If a connection is not obtained in less than ?timeout
, the connection is canceled and and the next socket address (if it exists) is tried.
val with_connection :
?timeout:Ptime.Span.t ->
addr ->
(Lwt_unix.file_descr ->
'a Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t) ->
'a Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t
val bind :
?backlog:int ->
addr ->
Lwt_unix.file_descr list Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t
val send :
Lwt_unix.file_descr ->
'a Mavryk_base.TzPervasives.Data_encoding.t ->
'a ->
unit Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t
val recv :
?timeout:Ptime.Span.t ->
Lwt_unix.file_descr ->
'a Mavryk_base.TzPervasives.Data_encoding.t ->
'a Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t
val handshake :
Lwt_unix.file_descr ->
bytes ->
unit Mavryk_base.TzPervasives.Error_monad.tzresult Lwt.t
handshake socket magic_bytes
is a function to synchronize two separate processes and start a communication.
The scenario of the handshake is the following:
magic_bytes
,