[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: checking for a closed socket
On Tue, Feb 02, 2021 at 02:07:01PM -0500, Mouse wrote:
> > Is there a way to check if a connection has been closed without a
> > read() ?
> ioctl(FIONREAD), perhaps? But I suspect you mean "without an
> additional syscall", in which case I suspect there is not.
The additionnal syscall isn't an issue. the extra read may be.
Hum, now that I'm thinking about it, as poll(2) won't return if
POLLIN isn't in the watched event, that won't work anyway.
> I think the theory is: why does it matter? If you're not going to try
> to do I/O on it, then why do you care? And if you are, then can't the
> check for the peer having closed be implicit in the I/O attempt?
> Is there some reason it's difficult to do it that way?
The code can put a socket in "ignoring" state for various
(some of them are countermeasures against DOS I guess). In this state
the code don't want to read it, but still wants to be notified when the
remote end is clsoed (or the file descriptor will stay forever).
I think we should close the socket in any case (read error, or protocol
error) but this is something I have to check with Xen developers.
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
NetBSD: 26 ans d'experience feront toujours la difference
Main Index |
Thread Index |