Just a quick example of a tcp server that returns the current time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
To test, startup an erlang shell:
erl
Compile the daytime.erl file:
1> c(daytime).
{ok,daytime}
Startup the daytime server:
2> daytime:start().
<0.50.0>
Now in another terminal fire up telnet and connect to port 1313.
telnet localhost 1313
You should get something like this:
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Sun, Oct 12, 2008 11:33:26
Connection closed by foreign host.