aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tcp_reverse/src/reverse_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-11-15 14:06:15 +0200
committerLoïc Hoguin <[email protected]>2016-11-15 14:09:50 +0200
commitcf85152fff8fc09a8c95fdc1b24db274defb052e (patch)
tree7ab66dbd20c7b66fa59a84350f5c39ac9fd868c6 /examples/tcp_reverse/src/reverse_protocol.erl
parent2c93d8ef43dbae0f9a9a44d1c70d28195f2a0a40 (diff)
downloadranch-cf85152fff8fc09a8c95fdc1b24db274defb052e.tar.gz
ranch-cf85152fff8fc09a8c95fdc1b24db274defb052e.tar.bz2
ranch-cf85152fff8fc09a8c95fdc1b24db274defb052e.zip
Properly handle Ctrl+D in examples
Diffstat (limited to 'examples/tcp_reverse/src/reverse_protocol.erl')
-rw-r--r--examples/tcp_reverse/src/reverse_protocol.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/tcp_reverse/src/reverse_protocol.erl b/examples/tcp_reverse/src/reverse_protocol.erl
index 2c7c15b..80ed62c 100644
--- a/examples/tcp_reverse/src/reverse_protocol.erl
+++ b/examples/tcp_reverse/src/reverse_protocol.erl
@@ -38,7 +38,8 @@ init({Ref, Socket, Transport, _Opts = []}) ->
?TIMEOUT).
handle_info({tcp, Socket, Data}, State=#state{
- socket=Socket, transport=Transport}) ->
+ socket=Socket, transport=Transport})
+ when byte_size(Data) > 1 ->
Transport:setopts(Socket, [{active, once}]),
Transport:send(Socket, reverse_binary(Data)),
{noreply, State, ?TIMEOUT};