aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/test/telnet_server.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2014-03-10 01:40:14 +0100
committerPeter Andersson <[email protected]>2014-03-12 16:00:14 +0100
commit609349f6acac4b03b8cac53eb9ad456a2b2d5536 (patch)
tree73d79e54d48a77b3b711cf19941b6d3c433cc5ff /lib/common_test/test/telnet_server.erl
parentd6fb44e0575ecd022c30d5c6a7503c8849d98fa9 (diff)
downloadotp-609349f6acac4b03b8cac53eb9ad456a2b2d5536.tar.gz
otp-609349f6acac4b03b8cac53eb9ad456a2b2d5536.tar.bz2
otp-609349f6acac4b03b8cac53eb9ad456a2b2d5536.zip
Get ct_telnet_client to print all data from server to log
Diffstat (limited to 'lib/common_test/test/telnet_server.erl')
-rw-r--r--lib/common_test/test/telnet_server.erl16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/common_test/test/telnet_server.erl b/lib/common_test/test/telnet_server.erl
index 1760100d8e..eb90f18320 100644
--- a/lib/common_test/test/telnet_server.erl
+++ b/lib/common_test/test/telnet_server.erl
@@ -67,7 +67,7 @@ accept(#state{listen=LSock}=State) ->
io:format("[telnet_server] telnet_server stopped\n"),
ok;
R ->
- io:format("[telnet_server] connection to client"
+ io:format("[telnet_server] connection to client "
"closed with reason ~p~n",[R]),
accept(State)
end;
@@ -97,19 +97,19 @@ init_client(#state{client=Sock}=State) ->
dbg("Server sending: ~p~n",["login: "]),
R = case gen_tcp:send(Sock,"login: ") of
ok ->
- loop(State);
+ loop(State, 1);
Error ->
Error
end,
_ = gen_tcp:close(Sock),
R.
-loop(State) ->
+loop(State, N) ->
receive
{tcp,_,Data} ->
try handle_data(Data,State) of
{ok,State1} ->
- loop(State1)
+ loop(State1, N)
catch
throw:Error ->
Error
@@ -120,6 +120,14 @@ loop(State) ->
{error,tcp,Error};
stop ->
stopped
+ after
+ 500 ->
+ Report = lists:flatten(
+ io_lib:format("The CT Telnet Server says: "
+ "Iteration no ~w\r\n", [N])),
+ dbg("Server sending: ~s~n", [Report]),
+ gen_tcp:send(State#state.client, Report),
+ loop(State, N+1)
end.
handle_data([?IAC|Cmd],State) ->