Commits

jhwoodyatt  committed 4908db5

Add [`SOCK_SEQPACKET] to the allowed socket types in the [listen] function.
There is no support for that socket type yet, but we must make room for it.
When [setsockopt] fails, raise Unix_error with the right function name.

  • Participants
  • Parent commits f54d388

Comments (0)

Files changed (2)

File cf/cf_socket.ml

 external to_unix_file_descr:
     ('af,'st) t -> Unix.file_descr = "cf_socket_to_unix_file_descr"
 
-external domain_of_unit_sockaddr:
-    unit sockaddr_t -> unit domain_t = "cf_socket_domain_of_unit_sockaddr"
+external domain_of_sockaddr:
+    'af sockaddr_t -> 'af domain_t = "cf_socket_domain_of_sockaddr"
 
 external dup: (('af,'st) t as 'fd) -> 'fd = "cf_socket_dup"
 external dup2: (('af,'st) t as 'fd) -> 'fd -> unit = "cf_socket_dup2"
 external bind: ('af,'st) t -> 'af sockaddr_t -> unit = "cf_socket_bind"
 external connect: ('af,'st) t -> 'af sockaddr_t -> unit = "cf_socket_connect"
 external listen:
-    ('af, ([<`SOCK_STREAM] as 'st)) t -> int -> unit =
+    ('af, ([< `SOCK_STREAM | `SOCK_SEQPACKET ] as 'st)) t -> int -> unit =
     "cf_socket_listen"
 external accept:
-    ('af, ([<`SOCK_STREAM] as 'st)) t -> ('af, 'st) t * 'af sockaddr_t =
+    ('af, ([ `SOCK_STREAM ] as 'st)) t -> ('af, 'st) t * 'af sockaddr_t =
     "cf_socket_accept"
 
 let shutdown sock cmd = Unix.shutdown (to_unix_file_descr sock) cmd
     ('af, 'st) t -> string -> int -> int -> msg_flags_t -> int =
     "cf_socket_send"
 external sendto:
-    ('af, ([<`SOCK_DGRAM] as 'st)) t -> string -> int -> int ->
+    ('af, ([ `SOCK_DGRAM ] as 'st)) t -> string -> int -> int ->
     msg_flags_t -> 'af sockaddr_t -> int =
     "cf_socket_sendto_bytecode" "cf_socket_sendto_native"
 external recv:
     ('af, 'st) t -> string -> int -> int -> msg_flags_t -> int =
     "cf_socket_recv"
 external recvfrom:
-    ('af, ([<`SOCK_DGRAM] as 'st)) t -> string -> int -> int ->
+    ('af, ([ `SOCK_DGRAM ] as 'st)) t -> string -> int -> int ->
     msg_flags_t -> int * 'af sockaddr_t = "cf_socket_recvfrom"
 
 module type AF = sig

File cf/cf_socket.mli

 *)
 val to_unix_file_descr: ('af,'st) t -> Unix.file_descr
 
-(** Use [domain_of_unit_sockaddr sa] to obtain the socket domain identifier
+(** Use [domain_of_sockaddr sa] to obtain the socket domain identifier
     associated with a socket address of unknown address family.
 *)
-val domain_of_unit_sockaddr: unit sockaddr_t -> unit domain_t
+val domain_of_sockaddr: 'af sockaddr_t -> 'af domain_t
 
 (** Use [dup sock] to create a duplicate of socket descriptor [sock].  Raises
     [Unix.Error] if there is an error.
     connections with a backlog queue [n] spaces deep.  Raises [Unix.Error] if
     there is an error.
 *)
-val listen: ('af,([<`SOCK_STREAM] as 'st)) t -> int -> unit
+val listen: ('af,([< `SOCK_STREAM | `SOCK_SEQPACKET ] as 'st)) t -> int -> unit
 
 (** Use [accept sock] to accept a connected request on the listening socket
     [sock].  Returns a new socket descriptor and the socket address of the
     remote peer.  Raises [Unix.Error] if there is an error.
 *)
-val accept: ('af,([<`SOCK_STREAM] as 'st)) t -> ('af,'st) t * 'af sockaddr_t
+val accept: ('af,([ `SOCK_STREAM ] as 'st)) t -> ('af,'st) t * 'af sockaddr_t
 
 (** Use [shutdown sock cmd] to shutdown either sending or receiving (or both)
     on the socket [sock].  Raises [Unix.Error] if there is an error.
     substring of [buf].
 *)
 val sendto:
-    ('af, ([<`SOCK_DGRAM] as 'st)) t -> string -> int -> int ->
+    ('af, ([ `SOCK_DGRAM ] as 'st)) t -> string -> int -> int ->
     msg_flags_t -> 'af sockaddr_t -> int
 
 (** Use [recv sock buf pos len flags] to receive [len] octets into the string
     [len] do not correspond to a valid substring of [buf].
 *)
 val recvfrom:
-    ('af, ([<`SOCK_DGRAM] as 'st)) t -> string -> int -> int ->
+    ('af, ([ `SOCK_DGRAM ] as 'st)) t -> string -> int -> int ->
     msg_flags_t -> int * 'af sockaddr_t
 
 (** Use [getsockopt sock opt] to obtain the value associated with the socket