aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-11-01 18:05:40 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-11-01 18:05:40 +0000
commit343eedd542a30c183f2d134b7668d07cab0a5769 (patch)
tree617ebda57c15c6e8ab9997b649d011af93b7eb74 /socket.c
parent4d57dd138fc48e2e37756b97b9ac3662894b69a3 (diff)
downloadfetchmail-343eedd542a30c183f2d134b7668d07cab0a5769.tar.gz
fetchmail-343eedd542a30c183f2d134b7668d07cab0a5769.tar.bz2
fetchmail-343eedd542a30c183f2d134b7668d07cab0a5769.zip
Deal with connect(2) bug.
svn path=/trunk/; revision=465
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/socket.c b/socket.c
index f0020adf..9d716dcb 100644
--- a/socket.c
+++ b/socket.c
@@ -51,8 +51,19 @@ int clientPort;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
return (FILE *)NULL;
- if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
+
+ /*
+ * Return of connect(2) doesn't seem to reliably return -1 on
+ * ENETUNREACH failure
+ */
+ errno = 0;
+ connect(sock, (struct sockaddr *) &ad, sizeof(ad));
+ if (errno != 0);
+ {
+ close(sock);
return (FILE *)NULL;
+ }
+
return fdopen(sock, "r+");
}