--- CVS-latest/lib/connect.c Sun Jul 04 23:48:54 2004 +++ ./lib/connect.c Mon Aug 02 16:43:22 2004 @@ -428,31 +428,34 @@ return rc; } -/* Used within the multi interface. Try next IP address, return TRUE if no - more address exists */ +/* + * Used within the multi interface. Try next IP address. + * Return FALSE if no more address exists. + */ static bool trynextip(struct connectdata *conn, int sockindex, - long timeout, bool *connected) { curl_socket_t sockfd; Curl_addrinfo *ai; + int i; if(sockindex != FIRSTSOCKET) - return TRUE; /* no next */ + return FALSE; /* no next */ - ai = conn->ip_addr->ai_next; - - while (ai) { - sockfd = singleipconnect(conn, ai, timeout, connected); + for (i = 0, ai = conn->ip_addr->ai_next; ai; ai = ai->ai_next, i++) { + if (i < conn->ai_next_index) + continue; + conn->ai_next_index = i+1; + sockfd = singleipconnect(conn, ai, 0L, connected); if(sockfd != CURL_SOCKET_BAD) { /* store the new socket descriptor */ conn->sock[sockindex] = sockfd; - return FALSE; + return TRUE; } - ai = ai->ai_next; + break; } - return TRUE; + return FALSE; } /* @@ -514,14 +517,14 @@ } /* nope, not connected for real */ infof(data, "Connection failed\n"); - if(trynextip(conn, sockindex, allow-has_passed, connected)) { + if(!trynextip(conn, sockindex, connected)) { code = CURLE_COULDNT_CONNECT; } } else if(WAITCONN_TIMEOUT != rc) { /* nope, not connected */ infof(data, "Connection failed\n"); - if(trynextip(conn, sockindex, allow-has_passed, connected)) { + if(!trynextip(conn, sockindex, connected)) { int error = Curl_ourerrno(); failf(data, "Failed connect to %s:%d; %s", conn->host.name, conn->port, Curl_strerror(conn,error)); --- CVS-latest/lib/urldata.h Sun Jul 04 23:36:14 2004 +++ ./lib/urldata.h Mon Aug 02 16:37:21 2004 @@ -448,6 +448,7 @@ /* the particular host we use, in two different ways */ struct Curl_dns_entry *dns_entry; Curl_addrinfo *ip_addr; /* the particular IP we connected to */ + int ai_next_index; /* the next index into above ip_addr to try */ char protostr[16]; /* store the protocol string in this buffer */