setsockopt SO_REUSEADDR

Warren Young warren@etr-usa.com
Tue Oct 5 15:06:00 GMT 2004


Dave Korn wrote:

>   Because SO_REUSEADDR works _correctly_ on cygwin, perhaps?

Oh, I don't know about that.

As I see it, the purpose of SO_REUSEADDR is to allow a program to bind 
to a port that still has WAIT states on it.  (FIN_WAIT_x, TIME_WAIT, 
etc...see netstat(1) and the Stevens TCP/IP books.)  The stack normally 
disallows this because packets may still be "in flight" that might be 
misdelivered if a program re-binds to this port before the wait states 
expire.  A program setting this flag is saying to the stack, "yes, I'm 
willing to take the risk to avoid waiting".  Setting this flag is 
important on some systems, such as Unixware, where some states can take 
10 minutes or so to expire.

This is quite different from allowing two active listeners on a single 
port.  I can't see a good reason for this.  Which program accepts the 
connection?

In any case, this behavior is all handled by the things behind the 
Winsock API, not by Cygwin.  I suspect that the Cygwin API is very thin 
at this point, just passing calls straight through to Winsock.  This 
difference of interpretation of the BSD sockets API is not Cygwin's problem.

--
Warren Young, maintainer of the Winsock Programmer's FAQ
http://tangentsoft.net/wskfaq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list