1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980(*
* Copyright (C) 2016 Docker Inc
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)moduletypeFN=sig(** Call a blocking ('a -> 'b) function in a ('a -> 'b Lwt.t) context *)type('request,'response)t(** A function from 'request to 'response *)valcreate:('request->'response)->('request,'response)tvaldestroy:('request,'response)t->unitvalfn:('request,'response)t->'request->'responseLwt.t(** Apply the function *)endmoduletypeSOCKET=sigtypet(** A socket which supports I/O via Lwt *)typesockaddr(** A socket address *)valstring_of_sockaddr:sockaddr->stringvalcreate:unit->t(** [create ()] creates an unbound hypervisorsocket *)typefd(** A low-level file descriptor *)valto_fd:t->fdoption(** [to_fd t] returns the wrapped file descriptor. Note this only supports
blocking I/O *)valbind:t->sockaddr->unit(** [bind t sockaddr] binds [socket] to [sockaddr] *)vallisten:t->int->unit(** [listen t queue] *)valaccept:t->(t*sockaddr)Lwt.t(** [accept t] accepts a single connection *)valconnect:?timeout_ms:int->t->sockaddr->unitLwt.t(** [connect ?timeout_ms t sockaddr] connects to a remote partition *)valread:t->Cstruct.t->intLwt.t(** [read t buf] reads as many bytes as available into [buf] returning
the number of bytes read. *)valwrite:t->Cstruct.t->intLwt.t(** [write t buf] writes as many bytes from [buf] to [t] as will currently
fit inside [t]'s internal buffer, and return the number of bytes
written *)valclose:t->unitLwt.t(** [close t] closes a socket *)valshutdown_read:t->unitLwt.t(** [shutdown_read t] closes the read side of the socket *)valshutdown_write:t->unitLwt.t(** [shutdown_write t] closes the write side of the socket *)end