Re: async connect problem

From: J.R. Oldroyd <fbsd_at_opal.com>
Date: Thu, 5 May 2005 23:08:41 -0400
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.

Perhaps I should ask a different question.

Subsequent code to check the socket's status, something like:

	int n;
	socklen_t intsize = sizeof(int);

	getsockopt(f, SOL_SOCKET, SO_ERROR, (void*)&n, &intsize);
	if (n) ...

which works (with suitable cast adjustments) on Solaris, Linux,
Darwin, and yes, even on Windows, doesn't work here.

I have an alternative test that uses getpeername(), but I'm surprised
at the difference in behavior.

	-jr
Received on Fri May 06 2005 - 01:09:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:34 UTC