curl-library
Re: can't connect to server when linked with pthreads
Date: Tue, 1 Aug 2006 23:42:04 +0200 (CEST)
On Tue, 1 Aug 2006, Marshall Crocker wrote:
> [pid 18072] connect(6, {sa_family=AF_INET, sin_port=htons(80),
> sin_addr=inet_addr("X.X.X.X")}, 16) = -1 EINPROGRESS (Operation now in
> progress)
> [pid 18072] getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
> [pid 18072] close(6) = 0
> As you can see, immediately after the getsockopt, close is called. When I
> don't have pthreads linked, I see a poll on 6, getsockopt, and then send(6,
> "POST"...). So something is closing the socket before the send. Any ideas?
The magic is within lib/connect.c:singleipconnect().
It is supposed to do connect() and if EINPROGRESS is returned wait until the
connect has completed (which is used with poll or select) and once it says it
is complete that fact is verified by the call to getsockopt() (in the
verifyconnect() function in that same source file).
I can only suggest that you use a debugger or lots of printf()s to figure out
what's going on.
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2006-08-01