/* Implementation of portions of the example on pages 393-394 of Unix Network Programming Finds the full name of the machine you're on and then, using the full name, obtains its internet numeric address. */ #include #include #include #include main() {struct hostent HostInfo; char Machine[32]; gethostname(Machine,32); HostInfo=*gethostbyname(Machine); fprintf(stderr,"Host Official Name: %s\n",HostInfo.h_name); fprintf(stderr,"Internet Address: %s\n", inet_ntoa(*((struct in_addr *) *(HostInfo.h_addr_list)))); }