[erlang-questions] sending multiple packets on the same socket

Bengt Kleberg <>
Thu Oct 30 14:46:02 CET 2008


Greetings,

Have you checked (with tcpdump or similar) who it is that closes the
socket? Is it the server or the client?


bengt

On Thu, 2008-10-30 at 05:21 -0700, BOG BOG wrote:
> Hello everybody,
> 
> I have a little problem and I do not know how to resolve it.
> 
> I am writing a little client that must communicate with a server based on sessions:
> 
> Basically this is the scenario:
> 
> 1. client sends the login request to the server;
> 2. server responds with an welcome message
> 3. after that, client send other messages to the server, in this newly created session
> 4. the session is closed normally by the client issuing a closing message to the server.
> 
> The client is written in erlang, and the server in perl.
> 
> The problem:
> 
> I'm not able to keep the socket open in order to send successive packets to 
> the server, because the socket is automatically closed when the client receives the welcome message from the server.
> 
> I want to be able to make succesive calls to the pair
> gen_tcp:send(Socket, Packet),
> gen_tcp:recv(Socket, 0)
> 
> on the same socket (the socket is opened with the option {active, false}).
> 
> I've tried a statement like this upon socket creation:
> {ok, Socket} = gen_tcp:connect("epp.rotld.ro", 5544, [binary, {packet, 0},
>      {active, false}, {exit_on_close,false},        
>      {keepalive,true},{reuseaddr,true}]),
> 
> and to subsequent calls to inet:setopts(), but the socket behaves in the same way - it is closing after the first reply of the server.
> 
> Thank you very much,
> 
> bogdan
> 
> 
> 
> 
>       
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list