cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-2870221 ] cannot connect to localhost on Mac OS

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 29 Sep 2009 23:20:10 +0000

Bugs item #2870221, was opened at 2009-09-29 18:20
Message generated for change (Tracker Item Submitted) made by trmueller
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2870221&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Tom Mueller (trmueller)
Assigned to: Daniel Stenberg (bagder)
Summary: cannot connect to localhost on Mac OS

Initial Comment:
Using libcURL with pycurl on Mac OS X 10.4, I'm seeing a problem with establishing a connection to a server running on localhost. This is a transient problem, with a failure occurring about 80-90% of the time.

After much digging, the root cause of the problem appears to be in the connect.c file, the trynextip function. This function is supposed to return TRUE if there are no more addresses to try or if there is an error. Presumably, if it can try the next IP address and there is no error, then it should return FALSE. However, this function always returns TRUE. If I change the "break" statement within this function to "return FALSE", then my program is able to connect successfully to localhost every time. I'm seeing this problem on version 7.19.5. I checked the trunk, and the break statement is still there so I'm assuming that this has not yet been fixed.

The test program is attempting to connect using multi mode with non-blocking sockets enabled. On Mac OS, localhost resolves first to an IPv6 address and then to the IPv4 address (127.0.0.1). The program first attempts to connect on IPv6. The initial connect call returns -1 with an in progress errno. Then a select call is made to see if the connect has completed. If the first select returns 1, then waitconnect determines that the IPv6 connection failed, the IPv4 connection is tried and the program works. However, if the first select returns 0, then going back to the main do loop which eventually calls Curl_is_connected, which finds out that the connection failed, so trynextip is called, which returns TRUE (meaning the connection failed) even though the connection really would have succeeded eventually. So the transient nature of this problem all depends on whether that first select on the IPv6 connection attempt returns 0 or 1.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2870221&group_id=976
Received on 2009-09-30

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET