package eio

  1. Overview
  2. Docs
Effect-based direct-style IO API for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

eio-0.10.tbz
sha256=390f7814507b8133d6c25e3a67a742d731c7ca66252b287b1fb0e3ad4d10eecc
sha512=9c0c9088b178df9799aaae9deb803a802228f1329cbe452479c90e80a13985d9c364ea86ee14e4e759133940f9f6065c7e8ece509d176fb1e347c5320f00a494

doc/eio.unix/Eio_unix/Net/index.html

Module Eio_unix.NetSource

Extended network API with support for file descriptors.

Types

These extend the types in Eio.Net with support for file descriptors.

Sourceclass virtual stream_socket : object ... end
Sourceclass virtual datagram_socket : object ... end
Sourceclass virtual t : object ... end

Unix address conversions

Note: OCaml's Unix.sockaddr type considers e.g. TCP port 80 and UDP port 80 to be the same thing, whereas Eio regards them as separate addresses that just happen to have the same representation (a host address and a port number), so we have separate "of_unix" functions for each.

Sourceval sockaddr_of_unix_stream : Unix.sockaddr -> Eio.Net.Sockaddr.stream
Sourceval sockaddr_of_unix_datagram : Unix.sockaddr -> Eio.Net.Sockaddr.datagram
Sourcemodule Ipaddr : sig ... end

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

Creating or importing sockets

Sourceval import_socket_stream : sw:Eio.Std.Switch.t -> close_unix:bool -> Unix.file_descr -> stream_socket

import_socket_stream ~sw ~close_unix:true fd is an Eio flow that uses fd.

It can be cast to e.g. source for a one-way flow. The socket object will be closed when sw finishes.

The close_unix and sw arguments are passed to Fd.of_unix.

Sourceval import_socket_datagram : sw:Eio.Std.Switch.t -> close_unix:bool -> Unix.file_descr -> datagram_socket

import_socket_datagram ~sw ~close_unix:true fd is an Eio datagram socket that uses fd.

The socket object will be closed when sw finishes.

The close_unix and sw arguments are passed to Fd.of_unix.

Sourceval socketpair_stream : sw:Eio.Std.Switch.t -> ?domain:Unix.socket_domain -> ?protocol:int -> unit -> stream_socket * stream_socket

socketpair_stream ~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.

Sourceval socketpair_datagram : sw:Eio.Std.Switch.t -> ?domain:Unix.socket_domain -> ?protocol:int -> unit -> datagram_socket * datagram_socket

socketpair_datagram ~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.

Private API for backends

Sourceval getnameinfo : Eio.Net.Sockaddr.t -> string * string

getnameinfo sockaddr returns domain name and service for sockaddr.

OCaml

Innovation. Community. Security.