cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Connection check problems on windows with multi thread.

From: Bjorn Reese <breese_at_mail1.stofanet.dk>
Date: Thu, 14 Feb 2002 17:54:15 +0000

chicco wrote:

> After curl establish new connection (connect() in connect.c) it calls socketerror()
> even though the return code from connect() is - 0 which mean that the connection established.
> socketerror() is calling getsockopt() and it seems that in windows with a lot of threads working
> simultaneously this cause the problem.

It sounds as if you've found the cause of the problem. Caveat: I have not
looked at the code, so I am answering in more general terms below.

For non-blocking connects there are three different situations.

First, connect() returns 0. This means that the connection has been established
immediately.

Second, connect() returns -1 and errno set to EINPROGRESS (or EWOULDBLOCK or
EAGAIN depending on your platform). This means that it could not be determined
immediately whether the connection was established or rejected. To find out,
getsockopt() must be called when the socket is marked as readable (and/or
writable? I forget).

Third, connect() returns -1 and errno set to something else. This means that
the connection has been rejected immediately.
Received on 2002-02-14