X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/9f8c2accae45b8dcb8c4e26009230c5e87ed53b5..18f9660ed8965aa37f7f1222e913ff2a1ed0b004:/gameserv/sockhelp.cpp?ds=sidebyside diff --git a/gameserv/sockhelp.cpp b/gameserv/sockhelp.cpp index f679c78..a5af1e3 100644 --- a/gameserv/sockhelp.cpp +++ b/gameserv/sockhelp.cpp @@ -23,19 +23,14 @@ int atoport(char *service, char *proto) { int port; long int lport; - struct servent *serv; char *errpos; - /* First try to read it from /etc/services */ - serv = getservbyname(service, proto); - if (serv != NULL) - port = serv->s_port; - else { /* Not in services, maybe a number? */ lport = strtol(service,&errpos,0); if ( (errpos[0] != 0) || (lport < 1) || (lport > 65535) ) return -1; /* Invalid port address */ + port = htons(lport); - } + return port; } @@ -44,13 +39,7 @@ int atoport(char *service, char *proto) struct in_addr *atoaddr(char *address) { struct hostent *host; - static struct in_addr saddr; - /* First try it as aaa.bbb.ccc.ddd. */ - saddr.s_addr = inet_addr(address); - if (saddr.s_addr != 0) { - return &saddr; - } host = gethostbyname(address); if (host != NULL) { return (struct in_addr *) *host->h_addr_list;