static long hostname(const char* host) 
{ 
   struct hostent* hostent; 
   struct in_addr* addr; 

   if (!host || !strlen(host)) 
   { 
      //printf("no host name\n"); 
      return -1; 
   } 

   // 12-Aug-1999 - TMT 
   // Added this check for a numeric IP address because the simple 
   // test that existed before would incorrectly assume a numeric 
   // address if the first character of "host" was a digit. 
   // The new check is not foolproof, since an address like 454.412.325 
   // would be interpreted as a numeric IP address even though the 
   // highest number allowed in any quadrant is 255. 
   Bool isNumericAddr=TRUE; 
   int numDigitsFromSep=1; 
   for (int i=0; host[i]; i++) 
   { 
      if ((!isdigit(host[i]) && host[i]!='.') || numDigitsFromSep>3) 
      { 
         isNumericAddr=FALSE; 
         break; 
      } else { 
         if (host[i]=='.') 
            numDigitsFromSep=1; 
         else 
            ++numDigitsFromSep; 
      } 
   } 

   // if (!isdigit(*host)) 
   if (!isNumericAddr) 
   { 
      if ((hostent = gethostbyname((char*)host)) == 0) 
      { 
         //printf("no hostbyname(%s) err %d\n", host, sockErrno); 
         return -1; 
      } 
   } 
   else 
   { 
      unsigned long addr = inet_addr((char*)host); 

      // There seems to be some kind of problem with some WIN95 
      // machines, so bypass this stuff for now... 

      //if ((hostent = gethostbyaddr((char*)&addr, 4, PF_INET)) == 0) 
      //{ 
         //printf("no hostbyaddr(%s) err %d\n", host, sockErrno); 
         //return -1; 
         return addr; 
      //} 
   } 

   addr = (struct in_addr *) *(hostent->h_addr_list); 

   return addr[0].s_addr; 
} 