Mail Archives: cygwin/2001/07/16/15:56:17
On Mon, Jul 16, 2001 at 02:00:10PM -0400, Jonathan Kamens wrote:
> The reason why things are different if the process exits is because
> Winsock runs in user space. Windows can't leave something around
> finishing up with data transmission after the process exits. On Unix,
> on the other hand, sockets are handled in the kernel, and the kernel
> will happily maintain that state and finish transmitting the data even
> after the process which sent it is gone.
AFAICS, that's the most important observation. I never thought about
that.
> Perhaps as a compromise we could set SO_LINGER on all new sockets with
> a short timeout, say a few seconds, to give data time to flush.
No, that's incorrect. Excerpt from W. Richard Stevens, "UNIX Network
Programming Vol. 1, Network APIs: Sockets and XTI", 2nd Edition, p. 187:
If l_onoff is nonzero and l_linger is 0, TCP aborts the
connection when it is closed [...]. That is, TCP discards
any data still remaining [...]. This avoids TCP's TIME_WAIT
state, but in doing so leaves open the possibility of
another incarnation of this connection being created within
2MSL seconds and having old duplicate segments from the just
terminated connection being incorrectly delivered to the new
incarnation [...].
> Or, slightly more complex but slightly more correct, keep track of
> whether or not a socket was at some point shared between multiple
> processes (either as a result of a fork or as a result of sending a
> file descriptor between processes (does Cygwin support that?)). When
> a socket is first shared, we can set SO_LINGER as I described above.
> Then, when a socket is closed, check if it was ever shared and call
> shutdown if it wasn't.
Since Cygwin has currently no "device layer" (though planned for the
future) we have no sharing of data between duplicated and inherited
file descriptors, unfortunately.
> > I just have that page "Graceful Shutdown, Linger Options, and
> > Socket Closure" inside of MSDN, that's all.
>
> Amusingly enough, the link to that page on the "closesocket" page is
> invalid.
http://msdn.microsoft.com/library/en-us/winsock/hh/winsock/ovrvw3_3she.asp
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -