From 738b123164407d7d9067c82a2e856b450018a28f Mon Sep 17 00:00:00 2001 From: Hans Svensson Date: Mon, 7 May 2018 10:01:56 +0200 Subject: [PATCH] Report send result to caller --- src/enoise_connection.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/enoise_connection.erl b/src/enoise_connection.erl index 3957c5e..19979cc 100644 --- a/src/enoise_connection.erl +++ b/src/enoise_connection.erl @@ -160,8 +160,10 @@ handle_msgs(S = #state{ msgbuf = [Msg | Msgs], active = {once, Delivered}, owner handle_send(S = #state{ tcp_sock = TcpSock, tx = Tx }, Data) -> {ok, Tx1, Msg} = enoise_cipher_state:encrypt_with_ad(Tx, <<>>, Data), - gen_tcp:send(TcpSock, <<(byte_size(Msg)):16, Msg/binary>>), - {ok, S#state{ tx = Tx1 }}. + case gen_tcp:send(TcpSock, <<(byte_size(Msg)):16, Msg/binary>>) of + ok -> {ok, S#state{ tx = Tx1 }}; + Err = {error, _} -> {Err, S} + end. set_active(#state{ msgbuf = [], active = {once, _}, tcp_sock = TcpSock }) -> inet:setopts(TcpSock, [{active, once}]);