aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1999-11-06 21:55:19 +0000
committerEric S. Raymond <esr@thyrsus.com>1999-11-06 21:55:19 +0000
commit6a75e16b6942cb3be87298fd9ca0c7d65d81f952 (patch)
tree3bceb1ca26a94beff0ec40edca7034beff408560 /socket.c
parentdfff00af0a435d1a1646051f712240295997efb6 (diff)
downloadfetchmail-6a75e16b6942cb3be87298fd9ca0c7d65d81f952.tar.gz
fetchmail-6a75e16b6942cb3be87298fd9ca0c7d65d81f952.tar.bz2
fetchmail-6a75e16b6942cb3be87298fd9ca0c7d65d81f952.zip
Ready to send this to Mike.
svn path=/trunk/; revision=2649
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/socket.c b/socket.c
index 78859a4b..12cc56c7 100644
--- a/socket.c
+++ b/socket.c
@@ -117,7 +117,7 @@ int SockCheckOpen(int fd)
}
#endif /* __UNUSED__ */
-#if INET6
+#if INET6_ENABLE
int SockOpen(const char *host, const char *service, const char *options,
const char *plugin)
{
@@ -159,7 +159,7 @@ int SockOpen(const char *host, const char *service, const char *options,
return i;
};
-#else /* INET6 */
+#else /* INET6_ENABLE */
#ifndef HAVE_INET_ATON
#ifndef INADDR_NONE
#ifdef INADDR_BROADCAST
@@ -195,12 +195,34 @@ int SockOpen(const char *host, int clientPort, const char *options,
#ifndef HAVE_INET_ATON
inaddr = inet_addr(host);
if (inaddr != INADDR_NONE)
+ {
memcpy(&ad.sin_addr, &inaddr, sizeof(inaddr));
- else
#else
- if (!inet_aton(host, &ad.sin_addr))
-#endif /* HAVE_INET_ATON */
+ if (inet_aton(host, &ad.sin_addr))
{
+#endif /* HAVE_INET_ATON */
+ ad.sin_port = htons(clientPort);
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (sock < 0)
+ {
+ h_errno = 0;
+ return -1;
+ }
+ if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
+ {
+ int olderr = errno;
+ close(sock);
+ h_errno = 0;
+ errno = olderr;
+ return -1;
+ }
+#ifndef HAVE_INET_ATON
+ }
+#else
+ }
+#endif /* HAVE_INET_ATON */
+ else {
hp = gethostbyname(host);
if (hp == NULL)
@@ -248,27 +270,10 @@ int SockOpen(const char *host, int clientPort, const char *options,
errno = olderr;
return -1;
}
- } else {
- ad.sin_port = htons(clientPort);
-
- sock = socket(AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- {
- h_errno = 0;
- return -1;
- }
- if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
- {
- int olderr = errno;
- close(sock);
- h_errno = 0;
- errno = olderr;
- return -1;
- }
}
return(sock);
}
-#endif /* INET6 */
+#endif /* INET6_ENABLE */
#if defined(HAVE_STDARG_H)