Skip to content

Commit de3261b

Browse files
committed
Add sockaddr information to callback
1 parent 0ae41d4 commit de3261b

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

lib/lwt_unix_conduit.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val connect :
3131
val serve :
3232
mode:server_mode ->
3333
sockaddr:Lwt_unix.sockaddr ->
34-
?timeout:int -> (ic -> oc -> unit io) -> unit io
34+
?timeout:int -> (Lwt_unix.sockaddr -> ic -> oc -> unit io) -> unit io
3535

3636
val close_in : 'a Lwt_io.channel -> unit
3737
val close_out : 'a Lwt_io.channel -> unit

lib/lwt_unix_net.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ module Tcp_server = struct
5454
Lwt_unix.listen sock 15;
5555
sock) ()
5656

57-
let process_accept ?timeout callback (client,_) =
57+
let process_accept ?timeout callback (client, sockaddr) =
5858
Lwt_unix.setsockopt client Lwt_unix.TCP_NODELAY true;
5959
let ic = Lwt_io.of_fd ~mode:Lwt_io.input client in
6060
let oc = Lwt_io.of_fd ~mode:Lwt_io.output client in
6161

62-
let c = callback ic oc in
62+
let c = callback sockaddr ic oc in
6363
let events = match timeout with
6464
|None -> [c]
6565
|Some t -> [c; (Lwt_unix.sleep (float_of_int t)) ] in

lib/lwt_unix_net.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module Tcp_server : sig
3333
val init :
3434
sockaddr:Lwt_unix.sockaddr ->
3535
?timeout:int ->
36-
(input channel -> output channel -> unit Lwt.t) ->
36+
(Lwt_unix.sockaddr -> input channel -> output channel -> unit Lwt.t) ->
3737
unit Lwt.t
3838

3939
val close : input channel * output channel -> unit Lwt.t

lib/lwt_unix_net_ssl.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module Server = struct
4444
let t = Ssl.create_context Ssl.TLSv1 Ssl.Server_context
4545

4646
let accept fd =
47-
lwt (afd,_) = Lwt_unix.accept fd in
47+
lwt (afd,sockaddr) = Lwt_unix.accept fd in
4848
lwt sock = Lwt_ssl.ssl_accept afd t in
49-
return (chans_of_fd sock)
49+
return (sockaddr,chans_of_fd sock)
5050

5151
let listen ?(nconn=20) ?password ~certfile ~keyfile sa =
5252
let fd = Lwt_unix.socket (Unix.domain_of_sockaddr sa) Unix.SOCK_STREAM 0 in
@@ -59,8 +59,8 @@ module Server = struct
5959
Ssl.use_certificate t certfile keyfile;
6060
fd
6161

62-
let process_accept ~timeout callback (ic,oc) =
63-
let c = callback ic oc in
62+
let process_accept ~timeout callback (sockaddr,(ic,oc)) =
63+
let c = callback sockaddr ic oc in
6464
let events = match timeout with
6565
| None -> [c]
6666
| Some t -> [c; (Lwt_unix.sleep (float_of_int t)) ] in

lib/lwt_unix_net_ssl.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525
module Server : sig
2626
val accept :
2727
Lwt_unix.file_descr ->
28-
(Lwt_io.input_channel * Lwt_io.output_channel) Lwt.t
28+
(Lwt_unix.sockaddr * (Lwt_io.input_channel * Lwt_io.output_channel)) Lwt.t
2929

3030
val listen :
3131
?nconn:int ->
@@ -40,7 +40,7 @@ module Server : sig
4040
keyfile:string ->
4141
?timeout:int ->
4242
Lwt_unix.sockaddr ->
43-
(Lwt_io.input_channel -> Lwt_io.output_channel -> unit Lwt.t) ->
43+
(Lwt_unix.sockaddr -> Lwt_io.input_channel -> Lwt_io.output_channel -> unit Lwt.t) ->
4444
unit Lwt.t
4545
end
4646

0 commit comments

Comments
 (0)