Can gen_tcp:close() close a socket which is still sending?

John Haugeland <>
Sun Jun 14 03:08:45 CEST 2009

I have a defect that I don't fully understand.  When I dispatch
something by gen_tcp:send(...), I follow through with :close().
However, there's a sporadic pattern of the data getting cut off early.
 If I inject a delay between them, the problem disappears.

This seems to imply that :close() can close a socket which is still
sending data.  That isn't what I would have expected by comparison
from other languages, so I'm not entirely convinced I've understood
this correctly.

Is it safe to call :close() immediately after a large :send()?  If
not, what does one do instead?

More information about the erlang-questions mailing list