Skip to content

Commit 92d76ba

Browse files
author
Christopher Zimmermann
committed
add close_notify as raw SSL_shutdown
this is needed for sending EOF, aka one-way shutdown.
1 parent c6aea13 commit 92d76ba

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: src/lwt_ssl.ml

+7
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ let wait_write (fd, s) =
161161
Plain -> Lwt_unix.wait_write fd
162162
| SSL _ -> Lwt_unix.yield ()
163163

164+
let close_notify (fd, s) =
165+
match s with
166+
Plain ->
167+
Lwt.fail_invalid_arg
168+
"Lwt_ssl.close_notify: Expected SSL, but got Plain connection"
169+
| SSL s -> repeat_call fd (fun () -> Ssl.close_notify s)
170+
164171
let ssl_shutdown (fd, s) =
165172
match s with
166173
Plain -> Lwt.return_unit

Diff for: src/lwt_ssl.mli

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ val close : socket -> unit Lwt.t
7474
val in_channel_of_descr : ?buffer:Lwt_bytes.t -> socket -> Lwt_io.input_channel
7575
val out_channel_of_descr : ?buffer:Lwt_bytes.t -> socket -> Lwt_io.output_channel
7676

77+
val close_notify : socket -> int Lwt.t
7778
val ssl_shutdown : socket -> unit Lwt.t
7879

7980
val abort : socket -> exn -> unit

0 commit comments

Comments
 (0)