[lug] socket issues
D. Stimits
stimits at idcomm.com
Mon Aug 13 14:39:23 MDT 2001
David Trowbridge wrote:
>
> I just ran into a rather icky sockets problem. I need to be able to know
> when the other side closes the socket. I've tried poll()ing the socket for
> POLLHUP, but it doesn't seem to work. I know there has to be a way to
> figure out when the other side closes the socket without disrupting the
> protocol (winsock has a method, and I believe OpenTransport does as well).
The only "easy" thing to do is to know that when the socket is
"readable", but the content of the read is zero bytes, then the
connection is closed (assumes tcp/ip). This method can cause false
disconnects under hardware flow control during lag or connection
saturation (when buffers fill). Under tcp/ip, there is also a way to
mark a packet with "urgent" data, and somewhat inaccurately sometimes
this is labelled "out of band (OOB)" (real OOB probably uses a different
route than the tcp/ip through a reserved address range; sending the data
on the same tcp/ip socket precludes the definition of being truly "out
of band"). The actual data of OOB (a single byte within an otherwise
normal tcp/ip send) suffers from the same problems of hardware flow
control and saturation of connection, but the header information
notifying the other end of OOB does bypass hardware flow control, in the
sense that this header will always be sent, ahead of any data,
regardless of whether buffers are filled or not. The other end can use
OOB notification as a means of knowing the the sender is still
alive...simply discard any actual OOB data, and pay attention only to
the notification of OOB. A scheme where a socket send blocks can be used
to alternately issue an OOB notification; the receiving side can use the
OOB notification to start a short timer (of perhaps a few seconds), and
any blocked sends could be ignored during that time. Zero byte reads
should still be considered closure, but you'll be able to eliminate a
lot of false disconnects during write errors.
D. Stimits, stimits at idcomm.com
>
> Any ideas?
> Thanks in advance,
> -David
>
> -------------------
> David Trowbridge
> jupiter at flatirons.org
> http://jupiter.babylonia.flatirons.org
>
> "Base 8 is just like base 10 really...if you're missing two fingers"
> -Tom Lehrer
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
More information about the LUG
mailing list