package eio
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c1f04986b401094176494863dde1ca9b292b59fdc679a9d7023e558d80fb5b15
sha512=92ed8cf20300b8a4e0141bdbc373c0803c5a24530cb65852637d905fff4a5b956a8859a00a424034ff78c1112da9b0391194bcd558326168bdebd1ce683a8890
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.
Passing file descriptors
val send_msg :
[> `Platform of [> `Unix ] | `Socket | `Stream ] Eio.Std.r ->
?fds:Fd.t list ->
Cstruct.t list ->
unitLike Eio.Flow.write, but allows passing file descriptors (for Unix-domain sockets).
val recv_msg_with_fds :
[> `Platform of [> `Unix ] | `Socket | `Stream ] Eio.Std.r ->
sw:Eio.Std.Switch.t ->
max_fds:int ->
Cstruct.t list ->
int * Fd.t listLike Eio.Flow.single_read, but also allows receiving file descriptors (for Unix-domain sockets).
fd socket is the underlying FD of socket.
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.
val sockaddr_to_unix :
[< Eio.Net.Sockaddr.stream | Eio.Net.Sockaddr.datagram ] ->
Unix.sockaddrCreating or importing sockets
val import_socket_stream :
sw:Eio.Std.Switch.t ->
close_unix:bool ->
Unix.file_descr ->
[< `Unix_fd | stream_socket_ty ] Eio.Std.rimport_socket_stream ~sw ~close_unix 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.
val import_socket_listening :
sw:Eio.Std.Switch.t ->
close_unix:bool ->
Unix.file_descr ->
[< `Unix_fd | listening_socket_ty ] Eio.Std.rimport_socket_listening ~sw ~close_unix fd is an Eio listening 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.
val import_socket_datagram :
sw:Eio.Std.Switch.t ->
close_unix:bool ->
Unix.file_descr ->
[< `Unix_fd | datagram_socket_ty ] Eio.Std.rimport_socket_datagram ~sw ~close_unix 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.
val socketpair_stream :
sw:Eio.Std.Switch.t ->
?domain:Unix.socket_domain ->
?protocol:int ->
unit ->
[< `Unix_fd | stream_socket_ty ] Eio.Std.r
* [< `Unix_fd | stream_socket_ty ] Eio.Std.rsocketpair_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.
val socketpair_datagram :
sw:Eio.Std.Switch.t ->
?domain:Unix.socket_domain ->
?protocol:int ->
unit ->
[< `Unix_fd | datagram_socket_ty ] Eio.Std.r
* [< `Unix_fd | datagram_socket_ty ] Eio.Std.rsocketpair_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.
Socket options
type Eio.Net.Sockopt.t += | Sockopt_bool : Unix.socket_bool_option -> bool Eio.Net.Sockopt.t(*Wrap any Unix boolean socket option
*)| Sockopt_int : Unix.socket_int_option -> int Eio.Net.Sockopt.t(*Wrap any Unix integer socket option
*)| Sockopt_optint : Unix.socket_optint_option -> int option Eio.Net.Sockopt.t(*Wrap any Unix optional integer socket option
*)| Sockopt_float : Unix.socket_float_option -> float Eio.Net.Sockopt.t(*Wrap any Unix float socket option
*)
Generic wrappers for Unix socket options. This extends Eio.Net.Sockopt with support for any Unix socket option.
Private API for backends
getnameinfo sockaddr returns domain name and service for sockaddr.
type Effect.t += | Import_socket_stream : Eio.Std.Switch.t * bool * Unix.file_descr -> [ `Unix_fd | stream_socket_ty ] Eio.Std.r Effect.t| Import_socket_listening : Eio.Std.Switch.t * bool * Unix.file_descr -> [ `Unix_fd | listening_socket_ty ] Eio.Std.r Effect.t| Import_socket_datagram : Eio.Std.Switch.t * bool * Unix.file_descr -> [ `Unix_fd | datagram_socket_ty ] Eio.Std.r Effect.t| Socketpair_stream : Eio.Switch.t * Unix.socket_domain * int -> ([ `Unix_fd | stream_socket_ty ] Eio.Std.r * [ `Unix_fd | stream_socket_ty ] Eio.Std.r) Effect.t| Socketpair_datagram : Eio.Switch.t * Unix.socket_domain * int -> ([ `Unix_fd | datagram_socket_ty ] Eio.Std.r * [ `Unix_fd | datagram_socket_ty ] Eio.Std.r) Effect.t