[erlang-questions] Difference in 'close' for gen_tcp recv vs. active

Jacob <>
Wed Apr 9 14:56:20 CEST 2014


Hi,

On 09.04.2014 02:49, Fred Hebert wrote:
> The difference here is that we have a peer that actively closes the
> connection 

Does the peer use close(s) or shutdown(s, SHUT_WR) to "close" the
connection?

> and the packets are readable and detected as far as tcpdumps
> go. Things like FINs or RSTs. They're making it to our host,

It makes a difference here, whether these are FINs or RSTs. Just
receiving a FIN from the peer will not stop the OS from accepting for
and sending data to the peer.

> they're
> just entirely ignored unless we're willing to read undefined amounts of
> data from the buffer for the stack to apparently get access to them.

If the peer uses shutdown() only you have no choice with standard
sockets. You probably don't want to start using pcap.

> 99.99% of the time that's gonna be 0 bytes because of HTTP clients' rare
> tendency to pipeline requests.
> 
> I'm just extremely annoyed having to figure out a way to add in a buffer
> to carry possibly unlimited amounts of data to read from a socket so it
> can figure out if a FIN or RST was sent recently, but I guess that's the
> way we'll have to do it.
> 
> Oh well.

Regards

Jacob




More information about the erlang-questions mailing list