Affect_unix.UnixUnix module overriden with cooperative functions and actions.
Unix module so that there are few surprises when one is swapped for the other.Warning. Most of the functionality of this module relies on an Unix.unblocker being setup on the executing domain.
The full Unix module from the OCaml unix library is included here. It is hidden from the docs due to a suboptimal reading experience.
include module type of Unix
with type file_descr = Unix.file_descr
and …close_noerr is like Unix.close but never raises.
socket is like Unix.socket except it has cloexec set to true by default and it sets the socket to non-blocking mode with Unix.set_nonblock.
accept is a cooperative Unix.accept.
connect is a cooperative Unix.connect.
read is a cooperative Unix.read.
write is a cooperative Unix.write.
write is a cooperative Unix.single_write.
val wait_readable : Unix.file_descr -> 'tag -> 'tag Affect.Action.twait_readable fd tag is the action used by the read operations and accept. The action invocation is enabled and synchronizes with tag whenever the non-blocking file descriptor fd becomes available for reading.
val wait_writable : Unix.file_descr -> 'tag -> 'tag Affect.Action.twait_writable fd tag is the action used by the write operations and connect. The action invocation is enabled and synchronizes with tag whenever the non-blocking file descriptor fd becomes available for writing.
module Signal : sig ... endWaiting on signals.
val unblocker : unit -> Affect.Action.unblockerunblocker () is an action unblocker to use with Affect.Fun.Async.main for handling actions from Unix, Mtime and Ptime.
val main :
?sigpipe:Signal.handler ->
?domain_spawn:((unit -> unit) -> unit Stdlib.Domain.t) ->
?domain_count:int ->
?schedule:Affect.Fun.Async.Schedule.t ->
?handler:Affect.Fun.Async.Call_handler.t ->
(unit -> 'a) ->
'aInvoking main expands to:
Unix.Signal.set_and_restore Sys.sigpipe sigpipe @@ fun () ->
let unblocker = Unix.unblocker () in
Fun.Async.main ~unblocker ?domain_spawn ?domain_count ?schedule ?handler fThe default of sigpipe is Unix.Signal.handler.Ignore which is the right default.
Unix moduleconnect, assumes a non-blocking file descriptor, handle EINPROGRESS by invoking wait_readable and after that checks if an error occcured with Unix.getsockopt_errorsocket, after the socket is created it is directly set to non-blocking mode with a call to Unix.set_nonblockread, write, single_write assume a non-blocking file descriptor and handles EWOULDBLOCK and EAGAIN by invoking wait_readable or wait_writable.Signal module is added.