HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 32
Getting the Remote Host's Internet Address
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 32 highlights
Using Internet Stream Sockets Preparing Address Variables Field short sin_family u_short sin_port struct inaddr sin_addr Description Specifies the address family and should always be set to AF_INET. Specifies the port address. Assign this field when you bind the port address for the socket or when you get a port address for a specific service. Specifies the internet address. Assign this field when you get the internet address for the remote host. The server process only needs an address for its own socket. Your client process may not need an address for its local socket. Refer to the inet(7f) man page for more information on sockaddr_in. Getting the Remote Host's Internet Address gethostbyname obtains the internet address of the host and the length of that address (as the size of struct in_addr) from /etc/hosts or from NIS name server. gethostbyname and its parameters are described in the following table. Include files: System call: #include struct hostent *gethostbyname(name) char *name; Parameter Description of Contents name pointer to a valid host name (null-terminated string) INPUT Value host name string Function result: pointer to struct hostent containing internet address NULL pointer (0) if failure occurs. Example: 32 Chapter 2