cURL / Mailing Lists / curl-library / Single Mail

curl-library

Errors and multi interface

From: Gisle Vanem <giva_at_bgnett.no>
Date: Fri, 3 Dec 2004 15:50:17 +0100

This command provides the correct errors for each address:

curl.exe -v ubr3-ca3-0-sec.landg1.lb.home.nl
* Couldn't find host ubr3-ca3-0-sec.landg1.lb.home.nl in the .netrc file, using defaults
* About to connect() to ubr3-ca3-0-sec.landg1.lb.home.nl port 80
* Trying 10.254.176.1... * Timeout
* Trying 84.25.56.1... * Connection refused
* Trying 84.25.50.1... * Connection refused
* Trying 84.25.60.1... * Connection refused
* Trying 10.221.102.1... * Timeout
* Trying 84.31.232.1... * Connection refused
* Trying 10.243.80.1... * Timeout
* Trying 10.243.72.1... * Timeout
* Trying 84.25.54.1... * Connection refused
* Trying 217.120.127.1... * Connection refused
* Trying 84.25.58.1... * Connection refused
* Trying 84.25.52.1... * Connection refused
* Trying 10.221.96.1... * Timeout
* couldn't connect to host

(our misconfigured dutch friend once again).

But a modified version of multi-single.c only says "Connection failed"
for all addresses. I've come up with this patch to fix it:

--- connect.c 22 Nov 2004 13:28:44 -0000 1.123
+++ connect.c 3 Dec 2004 14:43:48 -0000
@@ -523,10 +523,18 @@
     }
   }
   else if(WAITCONN_TIMEOUT != rc) {
+ int error = 0;
+
     /* nope, not connected */
- infof(data, "Connection failed\n");
+ if (WAITCONN_FDSET_ERROR == rc) {
+ verifyconnect(sockfd, &error);
+ infof(data, "%s\n",Curl_strerror(conn,error));
+ }
+ else
+ infof(data, "Connection failed\n");
+
     if(trynextip(conn, sockindex, connected)) {
- int error = Curl_ourerrno();
+ error = Curl_ourerrno();
       failf(data, "Failed connect to %s:%d; %s",
             conn->host.name, conn->port, Curl_strerror(conn,error));
       code = CURLE_COULDNT_CONNECT;

But I'm not sure CSELECT_ERR guarantees an error is stored in
the socket.

--gv
Received on 2004-12-03