@@ -4,15 +4,36 @@ open Eio.Std
44
55 These extend the types in {!Eio.Net} with support for file descriptors. *)
66
7- type stream_socket_ty = [`Unix_fd | [ ` Generic | `Unix ] Eio.Net .stream_socket_ty ]
8- type datagram_socket_ty = [`Unix_fd | [ ` Generic | `Unix ] Eio.Net .datagram_socket_ty ]
9- type listening_socket_ty = [`Unix_fd | [ ` Generic | `Unix ] Eio.Net .listening_socket_ty ]
7+ type stream_socket_ty = [`Generic | `Unix ] Eio.Net .stream_socket_ty
8+ type datagram_socket_ty = [`Generic | `Unix ] Eio.Net .datagram_socket_ty
9+ type listening_socket_ty = [`Generic | `Unix ] Eio.Net .listening_socket_ty
1010type 'a stream_socket = ([> stream_socket_ty ] as 'a ) r
1111type 'a datagram_socket = ([> datagram_socket_ty ] as 'a ) r
1212type 'a listening_socket = ([> listening_socket_ty ] as 'a ) r
1313
1414type t = [`Generic | `Unix ] Eio.Net .ty r
1515
16+ (* * {2 Passing file descriptors} *)
17+
18+ val send_msg :
19+ [> `Platform of [>`Unix ] | `Socket | `Stream ] r ->
20+ ?fds : Fd .t list ->
21+ Cstruct .t list -> unit
22+ (* * Like {!Eio.Flow.write}, but allows passing file descriptors (for Unix-domain sockets). *)
23+
24+ val recv_msg_with_fds :
25+ [> `Platform of [>`Unix ] | `Socket | `Stream ] r ->
26+ sw :Switch .t ->
27+ max_fds :int ->
28+ Cstruct .t list ->
29+ int * Fd .t list
30+ (* * Like {!Eio.Flow.single_read}, but also allows receiving file descriptors (for Unix-domain sockets).
31+
32+ @param max_fds The maximum number of file descriptors to accept (additional ones will be closed). *)
33+
34+ val fd : [> `Platform of [> `Unix ] | `Socket ] r -> Fd .t
35+ (* * [fd socket] is the underlying FD of [socket]. *)
36+
1637(* * {2 Unix address conversions}
1738
1839 Note: OCaml's {!Unix.sockaddr} type considers e.g. TCP port 80 and UDP port
3455
3556(* * {2 Creating or importing sockets} *)
3657
37- val import_socket_stream : sw :Switch .t -> close_unix :bool -> Unix .file_descr -> stream_socket_ty r
58+ val import_socket_stream : sw :Switch .t -> close_unix :bool -> Unix .file_descr -> [ `Unix_fd | stream_socket_ty ] r
3859(* * [import_socket_stream ~sw ~close_unix:true fd] is an Eio flow that uses [fd].
3960
4061 It can be cast to e.g. {!source} for a one-way flow.
4162 The socket object will be closed when [sw] finishes.
4263
4364 The [close_unix] and [sw] arguments are passed to {!Fd.of_unix}. *)
4465
45- val import_socket_datagram : sw :Switch .t -> close_unix :bool -> Unix .file_descr -> datagram_socket_ty r
66+ val import_socket_datagram : sw :Switch .t -> close_unix :bool -> Unix .file_descr -> [ `Unix_fd | datagram_socket_ty ] r
4667(* * [import_socket_datagram ~sw ~close_unix:true fd] is an Eio datagram socket that uses [fd].
4768
4869 The socket object will be closed when [sw] finishes.
@@ -54,7 +75,7 @@ val socketpair_stream :
5475 ?domain : Unix .socket_domain ->
5576 ?protocol : int ->
5677 unit ->
57- stream_socket_ty r * stream_socket_ty r
78+ [ `Unix_fd | stream_socket_ty ] r * [ `Unix_fd | stream_socket_ty ] r
5879(* * [socketpair_stream ~sw ()] returns a connected pair of flows, such that writes to one can be read by the other.
5980
6081 This creates OS-level resources using [socketpair(2)].
@@ -65,7 +86,7 @@ val socketpair_datagram :
6586 ?domain : Unix .socket_domain ->
6687 ?protocol : int ->
6788 unit ->
68- datagram_socket_ty r * datagram_socket_ty r
89+ [ `Unix_fd | datagram_socket_ty ] r * [ `Unix_fd | datagram_socket_ty ] r
6990(* * [socketpair_datagram ~sw ()] returns a connected pair of flows, such that writes to one can be read by the other.
7091
7192 This creates OS-level resources using [socketpair(2)].
@@ -78,11 +99,11 @@ val getnameinfo : Eio.Net.Sockaddr.t -> (string * string)
7899
79100type _ Effect.t + =
80101 | Import_socket_stream :
81- Switch .t * bool * Unix .file_descr -> stream_socket_ty r Effect .t (* * See {!import_socket_stream} *)
102+ Switch .t * bool * Unix .file_descr -> [ `Unix_fd | stream_socket_ty ] r Effect .t (* * See {!import_socket_stream} *)
82103 | Import_socket_datagram :
83- Switch .t * bool * Unix .file_descr -> datagram_socket_ty r Effect .t (* * See {!import_socket_datagram} *)
104+ Switch .t * bool * Unix .file_descr -> [ `Unix_fd | datagram_socket_ty ] r Effect .t (* * See {!import_socket_datagram} *)
84105 | Socketpair_stream : Eio.Switch .t * Unix .socket_domain * int ->
85- (stream_socket_ty r * stream_socket_ty r ) Effect .t (* * See {!socketpair_stream} *)
106+ ([ `Unix_fd | stream_socket_ty ] r * [ `Unix_fd | stream_socket_ty ] r ) Effect .t (* * See {!socketpair_stream} *)
86107 | Socketpair_datagram : Eio.Switch .t * Unix .socket_domain * int ->
87- (datagram_socket_ty r * datagram_socket_ty r ) Effect .t (* * See {!socketpair_datagram} *)
108+ ([ `Unix_fd | datagram_socket_ty ] r * [ `Unix_fd | datagram_socket_ty ] r ) Effect .t (* * See {!socketpair_datagram} *)
88109[@@ alert "-unstable" ]
0 commit comments