Getting The Remote Host's Internet Address - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

Using Internet Stream Sockets
Preparing Address Variables
Field
short sin_family
u_short sin_port
struct inaddr
sin_addr
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:
#include <netdb.h>
System call:
struct hostent *gethostbyname(name)
char *name;
Parameter
Description of Contents
name
pointer to a valid host name
(null-terminated string)
Function result: pointer to struct hostent containing internet address
NULL pointer (0) if failure occurs.
Example:
32
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.
INPUT Value
host name string
Chapter 2

Advertisement

Table of Contents
loading

Table of Contents