diff --git a/core/includes/common.inc b/core/includes/common.inc
index f54f29a..524a791 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -825,10 +825,19 @@ function drupal_http_request($url, array $options = array()) {
 
   // Make sure the socket opened properly.
   if (!$fp) {
-    // When a network error occurs, we use a negative number so it does not
-    // clash with the HTTP status codes.
-    $result->code = -$errno;
-    $result->error = trim($errstr) ? trim($errstr) : t('Error opening socket @socket', array('@socket' => $socket));
+    if (!$errno) {
+      // If $errno is 0, it is an indication that the error occurred
+      // before the connect() call. This is most likely due to a problem
+      // initializing the socket.
+      $result->code = -1004;
+      $result->error = trim($errstr) ? trim($errstr) : t('Error initializing socket @socket', array('@socket' => $socket));
+    }
+    else {
+      // When a network error occurs, we use a negative number so it does not
+      // clash with the HTTP status codes.
+      $result->code = -$errno;
+      $result->error = trim($errstr) ? trim($errstr) : t('Error opening socket @socket', array('@socket' => $socket));
+    }
 
     // Mark that this request failed. This will trigger a check of the web
     // server's ability to make outgoing HTTP requests the next time that
