package eio

  1. Overview
  2. Docs

Extension of Eio for integration with OCaml's Unix module.

Note that OCaml's Unix module is not safe, and therefore care must be taken when using these functions. For example, it is possible to leak file descriptors this way, or to use them after they've been closed, allowing one module to corrupt a file belonging to an unrelated module.

type Eio.Exn.Backend.t +=
  1. | Unix_error of Unix.error * string * string
    (*

    Wrapper for embedding Unix.Unix_error errors.

    *)
type unix_fd = < unix_fd : [ `Peek | `Take ] -> Unix.file_descr >
val await_readable : Unix.file_descr -> unit

await_readable fd blocks until fd is readable (or has an error).

val await_writable : Unix.file_descr -> unit

await_writable fd blocks until fd is writable (or has an error).

module FD : sig ... end

Convert between Unix.file_descr and Eio objects.

module Ipaddr : sig ... end

Convert between Eio.Net.Ipaddr and Unix.inet_addr.

val sleep : float -> unit

sleep d sleeps for d seconds, allowing other fibers to run. This is can be useful for debugging (e.g. to introduce delays to trigger a race condition) without having to plumb Eio.Stdenv.mono_clock through your code. It can also be used in programs that don't care about tracking determinism.

val run_in_systhread : (unit -> 'a) -> 'a

run_in_systhread fn runs the function fn in a newly created system thread (a Thread.t). This allows blocking calls to be made non-blocking.

val socketpair : sw:Eio.Std.Switch.t -> ?domain:Unix.socket_domain -> ?ty:Unix.socket_type -> ?protocol:int -> unit -> socket * socket

socketpair ~sw () returns a connected pair of flows, such that writes to one can be read by the other. This creates OS-level resources using socketpair(2). Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

pipe sw returns a connected pair of flows src and sink. Data written to sink can be read from src. Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

module Private : sig ... end

API for Eio backends only.

module Ctf : sig ... end
val getnameinfo : Eio.Net.Sockaddr.t -> string * string

getnameinfo sockaddr returns domain name and service for sockaddr.

OCaml

Innovation. Community. Security.