Getting data out of a closing socket

Rudolph van Graan <>
Wed Jun 18 17:09:32 CEST 2003


Hi all,

I have a bit of a strange situation at hand. A socket in active, packet
mode:

{ok, Sock} = gen_tcp:connect(IP, Port, [list, {packet,
4},{active,true}]),

Basically, I send a request on the socket to the other side

gen_tcp:send(Sock,Datagram)

Decoding events from the socket like this [hiding some other unimportant
things like closing the socket etc]:

run(Sock) ->
    receive
	What ->
	    io:format("Recv ~w\n",[What]),
	    run(Sock)    
    after
	1000 ->
	    run(Sock)
    end;


So, 

I only get this from the socket:

Recv {tcp_closed,#Port<0.140>}

Looking at a packet trace on our firewall, I can see data arriving
before the close. I would have expected two messages here, first the
data and then the close. I have also tried coding this some routing with
a passive socket, same problem... Any ideas?

Thanks,

Rudolph




More information about the erlang-questions mailing list