Skip to content

Commit

Permalink
Add explicit 'connect' to socket stackv4
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Feb 3, 2015
1 parent 5346abc commit 113d6c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
12 changes: 1 addition & 11 deletions unix/tcpip_stack_socket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,10 @@ module Make(Console:V1_LWT.CONSOLE) = struct
let t, _ = Lwt.task () in
t (* TODO cancellation *)

let connect id =
let connect id udpv4 tcpv4 =
let { V1_LWT.console = c; interface; _ } = id in
let or_error fn t err =
fn t
>>= function
| `Error _ -> fail (Failure err)
| `Ok r -> return r
in
Console.log_s c "Manager: connect"
>>= fun () ->
or_error Udpv4.connect None "udpv4"
>>= fun udpv4 ->
or_error Tcpv4.connect None "tcpv4"
>>= fun tcpv4 ->
let udpv4_listeners = Hashtbl.create 7 in
let tcpv4_listeners = Hashtbl.create 7 in
let t = { id; c; tcpv4; udpv4; udpv4_listeners; tcpv4_listeners } in
Expand Down
24 changes: 14 additions & 10 deletions unix/tcpip_stack_socket.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

module Make(Console:V1_LWT.CONSOLE) : V1_LWT.STACKV4
with type console = Console.t
and type netif = Ipaddr.V4.t list
and type mode = unit
and type tcpv4 = Tcpv4_socket.t
and type udpv4 = Udpv4_socket.t
and type ipv4 = Ipaddr.V4.t option
and module UDPV4 = Udpv4_socket
and module TCPV4 = Tcpv4_socket
and module IPV4 = Ipv4_socket
module Make(Console:V1_LWT.CONSOLE) : sig
include V1_LWT.STACKV4
with type console = Console.t
and type netif = Ipaddr.V4.t list
and type mode = unit
and type tcpv4 = Tcpv4_socket.t
and type udpv4 = Udpv4_socket.t
and type ipv4 = Ipaddr.V4.t option
and module UDPV4 = Udpv4_socket
and module TCPV4 = Tcpv4_socket
and module IPV4 = Ipv4_socket
val connect : (console, netif, mode) V1_LWT.stackv4_config ->
Udpv4_socket.t -> Tcpv4_socket.t -> [> `Ok of t | `Error of error ] Lwt.t
end

0 comments on commit 113d6c0

Please sign in to comment.