aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2005-08-02 00:41:50 +0000
committerMatthias Andree <matthias.andree@gmx.de>2005-08-02 00:41:50 +0000
commit2cabbf89f9f696a4786476a4eda7a59a1c16d486 (patch)
tree83657a863dfb434ab4a07edcc90781db848b84e0 /socket.c
parentaeec83fe86d05c61cc19ae8cb4cf07e959ab9ba1 (diff)
downloadfetchmail-2cabbf89f9f696a4786476a4eda7a59a1c16d486.tar.gz
fetchmail-2cabbf89f9f696a4786476a4eda7a59a1c16d486.tar.bz2
fetchmail-2cabbf89f9f696a4786476a4eda7a59a1c16d486.zip
Remove port/service dualism and make everything a service.
svn path=/trunk/; revision=4219
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/socket.c b/socket.c
index 80caa303..dc1d960d 100644
--- a/socket.c
+++ b/socket.c
@@ -319,7 +319,7 @@ int SockOpen(const char *host, const char *service,
#endif
#endif /* HAVE_INET_ATON */
-int SockOpen(const char *host, int clientPort,
+int SockOpen(const char *host, const char *service,
const char *plugin)
{
int sock = -1; /* pacify -Wall */
@@ -328,6 +328,7 @@ int SockOpen(const char *host, int clientPort,
#endif /* HAVE_INET_ATON */
struct sockaddr_in ad, **pptr;
struct hostent *hp;
+ int clientPort = servport(service);
#ifdef HAVE_SOCKETPAIR
if (plugin) {
@@ -337,6 +338,9 @@ int SockOpen(const char *host, int clientPort,
}
#endif /* HAVE_SOCKETPAIR */
+ if (clientPort < 0)
+ return sock;
+
memset(&ad, 0, sizeof(ad));
ad.sin_family = AF_INET;
@@ -359,11 +363,11 @@ int SockOpen(const char *host, int clientPort,
return -1;
}
- /* Socket opened saved. Usefull if connect timeout because
- * it can be closed
- */
- mailserver_socket_temp = sock;
-
+ /* Socket opened saved. Usefull if connect timeout because
+ * it can be closed
+ */
+ mailserver_socket_temp = sock;
+
if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
{
int olderr = errno;
@@ -1072,7 +1076,7 @@ static ssize_t cygwin_read(int sock, void *buf, size_t count)
* inetd.conf (and then SIGHUP inetd) for this to work. */
main()
{
- int sock = SockOpen("localhost", 19, NULL);
+ int sock = SockOpen("localhost", "chargen", NULL);
char buf[80];
while (SockRead(sock, buf, sizeof(buf)-1))