Re: Portable way to close() and prevent RST with non-empty receive queue?
From: Daniel C. Bastos (dbast0s_at_yahoo.com.br)
Date: Mon, 21 Nov 2005 18:23:46 +0000 (UTC)
In article <firstname.lastname@example.org>,
Andrei Voropaev wrote:
> On 2005-11-17, Thomas Kho <email@example.com> wrote:
>> I'm implementing a HTTP monitoring server that responds to all requests
>> with the same reply, and in the process doesn't bother to read the
>> request. On Linux 2.6.14 without the shutdown(), the client gets a RST
>> instead of the connection properly closing.
> Nothing will help. If you close connection without reading the input
> stream, and the client doesn't check for EOF(FIN) before trying to write
> (or has put already lots of data in the out-buffer) then the client will
> receive RST. Shutdown is really of no help here. That's just a way to
> signal to remote side that you are done with writing and it may start
> sending, or to signal kernel that you don't want to read from the socket
> anymore. RST is sent by the kernel when it receives data for the socket
> that doesn't do reading anymore or is closed. So, if you don't read, RST
> will be sent when client attempts to send something.
As far as I am able to verify, only by closing the socket an RST will
be sent if more data arrives. So, the ``doesn't do reading anymore''
case doesn't seem to be true. If it is, how do you do it? My tests
were made only on FreeBSD.