1. : How to determine if a (TCP) socket has closed without reading
I need to be able to consistently determine when the remote side of a TCP
socket has closed.
I know that if you read eof from the socket that often means it has closed,
but if you don't get eof, then you have to consume data. I could live with
that, but when the socket is set to nonblocking, receiving eof is ambiguous.
It could just mean that there was no data immediately available.
SIGPIPE might occur when attempting to read from a closed socket (is this
consistent?), but again there is the problem of potentially consuming data.
I wanted to find some way of polling for or of being notified when TCP sockets
close. For example, in System V's TLI interface, you can call t_rcvdis to
receive notification of a closed connection.
My program uses select to handle a list of sockets with a single process and
puts the sockets in nonblocking mode, so as a workaround, I decided to set the
highwater mark less than the lowwater mark so I could get a list of only
closed sockets and sockets with errors from select. I'm only afraid that this
could cause some unexpected behavior in other processes or kernel processes if
my program is interrupted while the buffer size indicators are set that way.
Does anyone know of any specific problems that could be caused?
Also, does anyone know of a cleaner, better (more portable) way to acheive
I'm using Linux kernel v.2.0.36 from Debian 2.1, but I'd like to make my code
as portable as possible.
Thanks in advance!
2. cannot PING itself
3. Determining when a remote socket has been closed
4. Preferred backup?
5. shutdown(s, 2) vs close(s) for closing unix domain sockets
6. User's group in PB County
7. Sockets: close() does not close!?
8. Which Monitor with Stealth 64 Video VRAM
9. Closing sockets and closing connections
10. socket close doesn't really close
11. determine throughput from LAN to Internet, Durchsatz vom LAN ins Internet berechnen
12. Reclaiming used socket fd or how to close sockets properly
13. help: close(socket) leaves socket bound ?