Using the gethostbyname(3) Function or gethostbyname c
This is the most important function to learn about in this chapter. This function accepts the name of the host that you want to resolve, and it returns a structure identifying it in various ways. The function synopsis is as follows:
extern int h_errno;
struct hostent *gethostbyname(const char *name);
The function gethostbyname(3) accepts one input argument that is a C string representing the hostname that you want to resolve into an address. The value returned is a pointer to the hostent
structure if the call is successful (see struct hostent). If the function fails, then a NULL pointer is returned, and the value of h_errno contains the reason for the failure.
IPC Advance Socket Concepts and Example Codes