Hello FreeBSD'ers...

I've been developing an application that attempts to send data from
one host to another via TCP.  The intent is for the data transfer
to be as reliable as possible, and to log whenever it detects
that it has lost data (this is for a reliable syslog protocol,
if you're wondering).  Because my application doesn't (yet) have
application-level acknowledgments, it has to depend on TCP to make
sure the data gets through reliably.

When closing the socket, I want to make sure that the remaining data
got through to the other end (or otherwise log something if it didn't).
I've set SO_LINGER on the socket for this purpose, but one caveat is
that I also have the socket in non-blocking mode.

My question is, what is the behavior of close() on a socket in
non-blocking mode when SO_LINGER is set (to a non-zero time)?

There seems to be two, possibly three, possibilities according to
some web searches I've done:

1) the close() call immediately returns with an EWOULDBLOCK (EAGAIN)
2) the call blocks anyway regardless of the non-blocking mode setting.
3) the call returns immediately after the connection is forcibly reset,
   possibly losing any queued data that was to be sent.

I'm pretty sure the third possibility only happens when SO_LINGER is
set with a linger time of 0 seconds.

Any ideas?  It would be really nice if the man pages could document
this particular case.

In the Year 2000 (tm)... "I will convert to Judasism and change my
trademark Fa Shizzle My Nizzle to Sheiztle Fa Zeitzel." -- Snoop Dog
[EMAIL PROTECTED] mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to