Module Lwt_unix


module Lwt_unix: sig .. end
Module Lwt_unix: thread-compatible system calls

val sleep : float -> unit Lwt.t
sleep d is a threads which remain suspended for d seconds (letting other threads run) and then terminates.
val yield : unit -> unit Lwt.t
yield () is a threads which suspends itself (letting other thread run) and then resumes as soon as possible and terminates.
val run : 'a Lwt.t -> 'a
run t lets the thread t run until it terminates. It evaluates to the return value of t, or raise the exception associated to t if t fails.

You should avoid using run inside threads:



These functions behave as their Unix counterparts, but let other threads run while waiting for the completion of the system call.
type file_descr 
val read : file_descr -> string -> int -> int -> int Lwt.t
val write : file_descr -> string -> int -> int -> int Lwt.t
val wait_read : file_descr -> unit Lwt.t
waits (without blocking other threads) until there is something to read on the file descriptor
val wait_write : file_descr -> unit Lwt.t
waits (without blocking other threads) until it is possible to write on the file descriptor
val pipe : unit -> file_descr * file_descr
val pipe_in : unit -> file_descr * Unix.file_descr
val pipe_out : unit -> Unix.file_descr * file_descr
val socket : Unix.socket_domain -> Unix.socket_type -> int -> file_descr
val socketpair : Unix.socket_domain ->
Unix.socket_type -> int -> file_descr * file_descr
val bind : file_descr -> Unix.sockaddr -> unit
val listen : file_descr -> int -> unit
val accept : file_descr -> (file_descr * Unix.sockaddr) Lwt.t
val connect : file_descr -> Unix.sockaddr -> unit Lwt.t
val shutdown : file_descr -> Unix.shutdown_command -> unit
val close : file_descr -> unit
val setsockopt : file_descr -> Unix.socket_bool_option -> bool -> unit
val set_close_on_exec : file_descr -> unit
val wait : unit -> (int * Unix.process_status) Lwt.t
val waitpid : Unix.wait_flag list -> int -> (int * Unix.process_status) Lwt.t
val system : string -> Unix.process_status Lwt.t

Aborting a connection
val abort : file_descr -> exn -> unit
Makes all current and further uses of the file descriptor fail with the given exception

File descriptor wrappings/unwrappings
val unix_file_descr : file_descr -> Unix.file_descr
val of_unix_file_descr : Unix.file_descr -> file_descr