This is the mail archive of the cygwin-developers@cygwin.com 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]

subtle problem with bind() semantics breaks bindresvport()


FYI, there appears to be a subtle difference in the semantics of winsock
bind() that makes Cygwin behave differently than UNIX.

I am seeing the problem in bindresvport() in librpc.a but it looks
like this may have been seen before in ftpd if I read the mailing list
archives correctly.

On a UNIX machine, bind() will return EADDRINUSE if an attempt is made
to bind to a port that is already bound.  Winsock is subtly different.
If you use INADDR_ANY for the socket address in the bind(), you can
succeed with bind() but later on fail with connect() -- Windows is
delaying the test until it can determine whether the (proto, port,
address) triple is unique.

This breaks the usual UNIX implementation of bindresvport() that just
scans through successive ports trying bind() until one succeeds.  So
I am seeing failing rpc calls because bindresvport() is picking a
port number that Windows later refuses to use in connect().
--
Joe Buehler


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