[erlang-questions] How to write a TCP server in Erlang?

Matej Kosik kosik@REDACTED
Thu Jun 14 22:05:06 CEST 2007


Hello,

Can somebody recommend me some great tutorials on TCP servers (and clients) written in Erlang? The reference manual is quite clear, however according to that information I am failing to implement what I need (I am ashamed).

The attached code works. A single packet is successfully transmitted from the client to the server. However, if I try to send another packet, the `recv' operation at server side instead of returning

	{ok, SomeBinaryData}

Returns

	{error,closed}

That is, the socket gets closed immediatelly after the first receive.

How to do these two transmissions correctly? For example, how to write a simple TCP server that for each connected client acts as an echo server (i.e. it sends back what it received)?

Thank you very much for any kind of helpful pointers.

Regards
-- 
Matej Kosik
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: server.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070614/89c9931b/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: client.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070614/89c9931b/attachment-0001.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070614/89c9931b/attachment.bin>


More information about the erlang-questions mailing list