diff options
-rw-r--r-- | examples/tcp_echo/src/echo_protocol.erl | 2 | ||||
-rw-r--r-- | examples/tcp_reverse/src/reverse_protocol.erl | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/examples/tcp_echo/src/echo_protocol.erl b/examples/tcp_echo/src/echo_protocol.erl index 5ed79b3..6e1df40 100644 --- a/examples/tcp_echo/src/echo_protocol.erl +++ b/examples/tcp_echo/src/echo_protocol.erl @@ -16,7 +16,7 @@ init(Ref, Socket, Transport, _Opts = []) -> loop(Socket, Transport) -> case Transport:recv(Socket, 0, 5000) of - {ok, Data} -> + {ok, Data} when Data =/= <<4>> -> Transport:send(Socket, Data), loop(Socket, Transport); _ -> 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}; |