Miou_unix
This module offers a re-implementation of the I/O according to Miou's model. It manages possible suspensions due to I/O
val of_file_descr : ?non_blocking:bool -> Unix.file_descr -> file_descr
of_file_descr ?non_blocking ?owner fd
creates a new file_descr
. Depending on non_blocking
(defaults to true
), we set the given fd
to non-blocking mode or not.
val to_file_descr : file_descr -> Unix.file_descr
to_file_descr fd
returns the real Unix.file_descr
.
val tcpv4 : unit -> file_descr
tcpv4 ()
allocates a new IPv4 socket.
val tcpv6 : unit -> file_descr
tcpv6 ()
allocates a new IPv6 socket.
val bind_and_listen : ?backlog:int -> file_descr -> Unix.sockaddr -> unit
bind_and_listen fd sockaddr
binds the given socket to the given sockaddr
and set up the given fd
for receiving connection requests. backlog
is the maximal number of pending requests.
val accept : ?cloexec:bool -> file_descr -> file_descr * Unix.sockaddr
accept ?cloexec fd
is a Miou friendly Unix.accept
which returns file descritptors in non-blocking mode.
val connect : file_descr -> Unix.sockaddr -> unit
connect fd sockaddr
is a Miou friendly Unix.connect
. The function accepts only file_descr
s in non-blocking mode.
val read : file_descr -> ?off:int -> ?len:int -> bytes -> int
read fd buf ~off ~len
reads up to len
bytes (defaults to Bytes.length buf - off
from the given file-descriptor fd
, storing them in byte sequence buf
, starting at position off
in buf
(defaults to 0
). It returns the actual number of characters read, between 0 and len
(inclusive).
val really_read : file_descr -> ?off:int -> ?len:int -> bytes -> unit
really_read fd buf ~off ~len
reads len
bytes (defaults to Bytes.length buf - off
) from the given file-descriptor fd
, storing them in byte sequence buf
, starting at position off
in buf
(defaults to 0
). If len = 0
, really_read
does nothing.
val write : file_descr -> ?off:int -> ?len:int -> string -> unit
write fd str ~off ~len
writes len
bytes (defaults to String.length str - off
) from byte sequence buf
, starting at offset off
(defaults to 0
), to the given file-descriptor fd
.
val close : file_descr -> unit
close fd
closes properly the given fd
.
module Ownership : sig ... end
/