@@ -4,9 +4,9 @@ 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
@@ -31,6 +31,9 @@ val recv_msg_with_fds :
3131
3232 @param max_fds The maximum number of file descriptors to accept (additional ones will be closed). *)
3333
34+ val fd : [> `Platform of [> `Unix ] | `Socket ] r -> Fd .t
35+ (* * [fd socket] is the underlying FD of [socket]. *)
36+
3437(* * {2 Unix address conversions}
3538
3639 Note: OCaml's {!Unix.sockaddr} type considers e.g. TCP port 80 and UDP port
5255
5356(* * {2 Creating or importing sockets} *)
5457
55- 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
5659(* * [import_socket_stream ~sw ~close_unix:true fd] is an Eio flow that uses [fd].
5760
5861 It can be cast to e.g. {!source} for a one-way flow.
5962 The socket object will be closed when [sw] finishes.
6063
6164 The [close_unix] and [sw] arguments are passed to {!Fd.of_unix}. *)
6265
63- 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
6467(* * [import_socket_datagram ~sw ~close_unix:true fd] is an Eio datagram socket that uses [fd].
6568
6669 The socket object will be closed when [sw] finishes.
@@ -72,7 +75,7 @@ val socketpair_stream :
7275 ?domain : Unix .socket_domain ->
7376 ?protocol : int ->
7477 unit ->
75- stream_socket_ty r * stream_socket_ty r
78+ [ `Unix_fd | stream_socket_ty ] r * [ `Unix_fd | stream_socket_ty ] r
7679(* * [socketpair_stream ~sw ()] returns a connected pair of flows, such that writes to one can be read by the other.
7780
7881 This creates OS-level resources using [socketpair(2)].
@@ -83,37 +86,24 @@ val socketpair_datagram :
8386 ?domain : Unix .socket_domain ->
8487 ?protocol : int ->
8588 unit ->
86- datagram_socket_ty r * datagram_socket_ty r
89+ [ `Unix_fd | datagram_socket_ty ] r * [ `Unix_fd | datagram_socket_ty ] r
8790(* * [socketpair_datagram ~sw ()] returns a connected pair of flows, such that writes to one can be read by the other.
8891
8992 This creates OS-level resources using [socketpair(2)].
9093 Note that, like all FDs created by Eio, they are both marked as close-on-exec by default. *)
9194
92- module Pi : sig
93- module type STREAM_SOCKET = sig
94- type t
95-
96- val send_msg : t -> fds :Fd .t list -> Cstruct .t list -> int
97-
98- val recv_msg_with_fds : t -> sw :Switch .t -> max_fds :int -> Cstruct .t list -> int * Fd .t list
99- end
100-
101- type (_, _, _) Eio.Resource.pi + =
102- | Stream_socket : ('t , (module STREAM_SOCKET with type t = 't ), [> `Platform of [> `Unix ] | `Socket | `Stream ]) Eio.Resource .pi
103- end
104-
10595(* * {2 Private API for backends} *)
10696
10797val getnameinfo : Eio.Net.Sockaddr .t -> (string * string )
10898(* * [getnameinfo sockaddr] returns domain name and service for [sockaddr]. *)
10999
110100type _ Effect.t + =
111101 | Import_socket_stream :
112- 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} *)
113103 | Import_socket_datagram :
114- 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} *)
115105 | Socketpair_stream : Eio.Switch .t * Unix .socket_domain * int ->
116- (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} *)
117107 | Socketpair_datagram : Eio.Switch .t * Unix .socket_domain * int ->
118- (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} *)
119109[@@ alert "-unstable" ]
0 commit comments