This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: setsockopt SO_REUSEADDR


On Oct  5 09:54, Brian Ford wrote:
> On Tue, 5 Oct 2004, Dave Korn wrote:
> 
> > > -----Original Message-----
> > > From: cygwin-owner On Behalf Of Rainer Hochreiter
> > > Sent: 05 October 2004 15:29
> >
> > > running the program listed below with argument 'reuse' under
> > > cygwin and linux returns different results!
> > >
> > > from my point of view, the linux result is quite what i
> > > expected, a bind() error 'Address already in use'.
> >
> >   Huh?  But that's exactly what SO_REUSEADDR is supposed to _prevent_
> > from happening.  That's why it's called _REUSE_addr, because it lets you
> > *re-use* an addr, without getting an error message.  Why would you
> > expect setting it to stop you from reusing the address?
> 
> I was about to say the same thing, but...
> 
> http://www.unixguide.net/network/socketfaq/4.5.shtml
> 
> It is only supposed to reuse if the other socket is in the TIME_WAIT
> state.  I think that is what he is complaining about.

That's not how it is implemented in WinSock, though.  That's the reason
it works even if the already existing socket is not in TIME_WAIT.  MSDN
states:

 SO_REUSEADDR 

   By default, a socket cannot be bound [...] to a local address that is
   already in use. On occasion, however, it can be necessary to reuse an
   address in this way. Since every connection is uniquely identified by
   the combination of local and remote addresses, there is no problem with
   having two sockets bound to the same local address as long as the remote
   addresses are different. [...]


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin@cygwin.com
Red Hat, Inc.

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]