Skip to content

Commit 5f954f4

Browse files
committed
Merge pull request #63 from adferguson/of10_send_fix2
exception handling handling for OpenFlow 1.0 (take 2)
2 parents e0cbd2a + 962360c commit 5f954f4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lwt/OpenFlow0x01_Switch.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ let rec recv_from_switch_fd (sock : file_descr) : (xid * msg) option Lwt.t =
3939
let send_to_switch_fd (sock : file_descr) (xid : xid) (msg : msg) : bool Lwt.t =
4040
lwt msg_buf = Lwt.wrap2 Message.marshal xid msg in
4141
let msg_len = String.length msg_buf in
42-
lwt sent = Lwt_unix.write sock msg_buf 0 msg_len in
43-
Lwt.return (sent = msg_len)
42+
try_lwt
43+
lwt sent = Lwt_unix.write sock msg_buf 0 msg_len in
44+
Lwt.return (sent = msg_len)
45+
with Unix.Unix_error (err, fn, arg) ->
46+
Printf.printf "[platform0x01] error sending: %s (in %s)\n%!"
47+
(Unix.error_message err) fn;
48+
Lwt.return (false)
4449

4550
let switch_handshake_finish (fd : file_descr) : OF.SwitchFeatures.t option Lwt.t =
4651
match_lwt send_to_switch_fd fd 0l Message.SwitchFeaturesRequest with

0 commit comments

Comments
 (0)