package hvsock

  1. Overview
  2. Docs

Create a Lwt socket from a

  • source of timing
  • a means of running blocking calls in full threads
  • a means of creating sockets

This is useful because some of the hypervisor sockets do not support select() or other methods of asynchronous I/O and we must therefore run the calls in background threads.

Parameters

module Fn : S.FN

Signature

type t

A socket which supports I/O via Lwt

type sockaddr = Socket_family.sockaddr

A socket address

val string_of_sockaddr : sockaddr -> string
val create : unit -> t

create () creates an unbound hypervisorsocket

type fd = Socket_family.t

A low-level file descriptor

val to_fd : t -> fd option

to_fd t returns the wrapped file descriptor. Note this only supports blocking I/O

val bind : t -> sockaddr -> unit

bind t sockaddr binds socket to sockaddr

val listen : t -> int -> unit

listen t queue

val accept : t -> (t * sockaddr) Lwt.t

accept t accepts a single connection

val connect : ?timeout_ms:int -> t -> sockaddr -> unit Lwt.t

connect ?timeout_ms t sockaddr connects to a remote partition

val read : t -> Cstruct.t -> int Lwt.t

read t buf reads as many bytes as available into buf returning the number of bytes read.

val write : t -> Cstruct.t -> int Lwt.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

val close : t -> unit Lwt.t

close t closes a socket

val shutdown_read : t -> unit Lwt.t

shutdown_read t closes the read side of the socket

val shutdown_write : t -> unit Lwt.t

shutdown_write t closes the write side of the socket

OCaml

Innovation. Community. Security.