--- curl-old/lib/connect.c	Tue Jul 13 16:26:44 2004
+++ curl/lib/connect.c	Fri Sep 24 15:38:46 2004
@@ -18,7 +18,7 @@
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  * KIND, either express or implied.
  *
- * $Id: //projects/shared/curl-7.12.0/akamai/curl/lib/connect.c#2 $
+ * $Id: //projects/shared/curl-7.12.0.1/akamai/curl/lib/connect.c#5 $
  ***************************************************************************/
 
 #include "setup.h"
@@ -370,7 +370,8 @@
         }
 #endif
         if(!bindworked) {
-          failf(data, "%s", Curl_strerror(conn, Curl_ourerrno()));
+	  data->state.os_errno = Curl_ourerrno();
+          failf(data, "%s", Curl_strerror(conn, data->state.os_errno));
           return CURLE_HTTP_PORT_FAILED;
         }
 	
@@ -491,17 +492,21 @@
   rc = waitconnect(sockfd, 0);
 
   if(0 == rc) {
-    if (verifyconnect(sockfd,NULL)) {
+    int error;
+    if (verifyconnect(sockfd,&error)) {
       /* we are connected, awesome! */
       *connected = TRUE;
       return CURLE_OK;
     }
     /* nope, not connected for real */
+    data->state.os_errno = error;
     failf(data, "Connection failed");
     return CURLE_COULDNT_CONNECT;
   }
   else if(1 != rc) {
-    int error = Curl_ourerrno();
+    int error;
+    (void)verifyconnect(sockfd,&error);
+    data->state.os_errno = error;
     failf(data, "Failed connect to %s:%d; %s",
           conn->host.name, conn->port, Curl_strerror(conn,error));
     return CURLE_COULDNT_CONNECT;
@@ -549,7 +554,7 @@
                           bool *connected)           /* really connected? */
 {
   struct SessionHandle *data = conn->data;
-  int rc, error;
+  int rc, error=0;
   curl_socket_t sockfd= CURL_SOCKET_BAD;
   int aliasindex=0;
   char *hostname;
@@ -704,7 +709,7 @@
     }
       
     if(0 == rc) {
-      if (verifyconnect(sockfd,NULL)) {
+      if (verifyconnect(sockfd,&error)) {
         /* we are connected, awesome! */
         *connected = TRUE; /* this is a true connect */
         break;
@@ -718,6 +723,7 @@
     /* connect failed or timed out */
     sclose(sockfd);
     sockfd = CURL_SOCKET_BAD;
+    data->state.os_errno = error;
 
     /* get a new timeout for next attempt */
     after = Curl_tvnow();

