#include "stock.h" int ip2name(int addr, char *name) int name2ip(char *name, struct in_addr *addr, char *ipc)
name2ip performs the inverse operation, calling gethostbyname(3) to find the ip address corresponding to a hostname. It returns both the ip address in addr, and the ascii representation of the inet address in ipc.
Both routines are thread safe because they employ mutexes to ensure that calls to the thread-unsafe gethostbyaddr and gethostbyname are serial.
if ( ip2name ( aclient->address, hostname) ) { complain ( 0, "Can't find address '%s'", hostname ) ; } if ( name2ip ( server, &serv_addr.sin_addr.s_addr, ipc ) ) { register_error ( 1, "Can't find host '%s'\n", server ) ; return -1 ; }
gethostbyaddr(3) gethostbyname(3)