gen_tcp:recv - last segement when closed port

jmT2 johan@REDACTED
Sat Mar 11 11:09:19 CET 2006


I have a problem using gen_tcp:recv(Socket, 0). If (when as it turns out  
in my application) the server port closes  the last segment is never  
returned. Using Ethereal I can see the last TCP packet containing 1199  
byts, but the last segement returned by recv/2 is as usual 1024 bytes. The  
remaining 175 bytes is never found. The next call to recv/2 will only  
return {error, closed} :-(

I havn't looked too carefully at what is happening but looking at the src  
 from gen_tcp and inet_db it looks like a call to erlang:port_get_data/1  
returns {error, closed} allthough there should be data in the buffer.

Is this a bug or am I doning something wrong. Do I have to rewrite it  
using active mode?

   Johan



-----------
Johan Montelius jmT2



More information about the erlang-questions mailing list