Commits

jhwoodyatt  committed 75c61bf

Move create and createpair from Iom_sock_stream to Iom_socket.

  • Participants
  • Parent commits 8bcc137

Comments (0)

Files changed (5)

   Iom_layer.transform and swapped the meaning of block/unblock with ready/wait
   in the tranformer state and its related process gadgets classes.
 + Merge [`Complete] indication in Iom_reactor with [`Wait].
++ Move [Iom_sock_stream.T.socket] to [Iom_socket.T.create] and add
+  [Iom_socket.T.createpair].
 
 ===== Version 0.3 =====
 

File iom/iom_sock_stream.ml

     
     type endpoint = endpoint_fix
     
-    val socket: unit -> t
-
     val initiator:
         ?s:t -> ?src:address -> dst:address -> Iom_gadget.kernel ->
         initiator Iom_gadget.t
     
     type endpoint = endpoint_fix
     
-    let socket () = 
-        (Nx_socket.create P.AF.domain P.ST.socktype P.protocol : t)
-    
     let addrsoptmap_ = function
         | None ->
             None
             Some (src, dst)
 
     class initiator0
-      ~k ?(s = socket ()) ?(src = unspecified_address) ~dst pad =
+      ~k ?(s = create ()) ?(src = unspecified_address) ~dst pad =
         let src = P.AF.to_sockaddr src in
         let dst = P.AF.to_sockaddr dst in
         object
         Iom_stream.ifix (new initiator0 ~k ?s ?src ~dst)
 
     class listener0
-      ~k ?(s = socket ()) ?(src = unspecified_address) ~backlog pad =
+      ~k ?(s = create ()) ?(src = unspecified_address) ~backlog pad =
         let src = P.AF.to_sockaddr src in
         object
             inherit [Iom_stream.flowcontrol, 'address listener_notify,
     let listener ?s ?src ~backlog k =
         Iom_stream.ifix (new listener0 ~k ?s ?src ~backlog)
 
-    class endpoint0 ~k ?(s = socket ()) ?addrs ~limits pad =
+    class endpoint0 ~k ?(s = create ()) ?addrs ~limits pad =
         let addrs = addrsoptmap_ addrs in
         object
             inherit [Iom_octet_stream.fragment, Iom_octet_stream.fragment,

File iom/iom_sock_stream.mli

     
     (** The fix for controlling a socket endpoint gadget. *)
     type endpoint = endpoint_fix
-    
-    (** Use [socket ()] as convenient constructor for socket descriptors. *)
-    val socket: unit -> t
 
     (** Evaluate [initator ?s ?src ~dst k] to obtain the fix for a connection
         initiator to the destination [dst] in the kernel context [k].  If [src]

File iom/iom_socket.ml

     type t = (P.AF.tag, P.ST.tag) Nx_socket.t
     type address = P.AF.address
     val unspecified_address: address
+    val create: unit -> t
+    val createpair: unit -> t * t
 end
 
 module Create(P: Nx_socket.P) = struct
     type t = (P.AF.tag, P.ST.tag) Nx_socket.t
     type address = P.AF.address
     let unspecified_address = P.AF.of_sockaddr P.AF.unspecified
+    
+    let create () = 
+        (Nx_socket.create P.AF.domain P.ST.socktype P.protocol : t)
+    
+    let createpair () = 
+        (Nx_socket.createpair P.AF.domain P.ST.socktype P.protocol : t * t)
 end
 
 (*--- End of File [ iom_socket.ml ] ---*)

File iom/iom_socket.mli

     
     (** The "unspecified" address for the socket. *)
     val unspecified_address: address
+
+    (** Use [socket ()] as a convenient constructor for socket descriptors. *)
+    val create: unit -> t
+    
+    (** Use [socketpair ()] as a convenient constructor for the descriptors to
+        a pair of connected sockets. *)
+    val createpair: unit -> t * t
 end
 
 (** Use [Create(P)] to compose a module for including in modules for specific