async connect problem

J.R. Oldroyd jr at opal.com
Thu May 5 22:16:41 PDT 2005


On May 05, 23:08, J.R. Oldroyd wrote:
> On May 05, 19:39, Brian Buchanan wrote:
> > On Thu, 5 May 2005, J.R. Oldroyd wrote:
> > 
> > >Isn't our behaviour wrong...
> > >
> > >On 6-current, the program below prints:
> > >	connect: Connection refused
> > >
> > >Shouldn't it print:
> > >	connect: Operation now in progress
> > 
> > No, that's the correct behavior.  The system was able to satisfy your 
> > request without blocking because you were attempting a connection to the 
> > loopback, so connect() returned immediately with errno == ECONNREFUSED.
> > 
> > - Brian
> 
> You are correct, it does return EINPROGRESS when using a non-loopback
> address.
> 

Even more surprising: on further investigation, running that program
with 127.0.0.1 or my own Ethernet address is inconsistent: it mostly
returns ECONNREFUSED but it does return EINPROGRESS occasionally
too.  In several runs of 100 invocations each, I'm seeing anything
from 0% to 18% of the results be EINPROGRESS - that's using the
same local IP and port every time.

Running it with the IP address of another host returns EINPROGRESS
100% of the time.

The getsockopt() call does appear to succeed in those cases where
EINPROGRESS is returned.

Given the inconsistent behavior between the local and non-local
addresses and the self-inconsistent behavior in the local case, it
seems that we may have an issue here.

	-jr

PS: I meant getsockopt(s, ...) before.  The "f" was a typo.


More information about the freebsd-current mailing list