From 2cabbf89f9f696a4786476a4eda7a59a1c16d486 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Tue, 2 Aug 2005 00:41:50 +0000 Subject: Remove port/service dualism and make everything a service. svn path=/trunk/; revision=4219 --- socket.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'socket.c') 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)) -- cgit v1.2.3