in_addr_t lookupIp(char *host)
/* Return IP address of host. */
{
static char *lastHost = NULL;
static in_addr_t lastAddress;

if (lastHost != NULL && sameString(lastHost, host))
    return lastAddress;
freez(&lastHost);
lastHost = cloneString(host);
lastAddress = internetHostIp(host);
return lastAddress;
}
Ejemplo n.º 2
0
boolean internetFillInAddress(char *hostName, int port, struct sockaddr_in *address)
/* Fill in address. Return FALSE if can't.  */
{
ZeroVar(address);
address->sin_family = AF_INET;
address->sin_port = htons(port);
if (hostName == NULL)
    address->sin_addr.s_addr = INADDR_ANY;
else
    {
    if ((address->sin_addr.s_addr = htonl(internetHostIp(hostName))) == 0)
	return FALSE;
    }
return TRUE;
}