Getting The Remote Host's Network 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

Field
short sin_family
u_short sin_port
struct in_addr
sin_addr
The server process must bind the port address of the service to its own
socket and establish an address structure to store the clients' addresses
when they are received with recvfrom. The client process does not have
to bind a port address for its local socket; the host binds one
automatically if one is not already bound. Refer to the inet(7F) man
page for more information on sockaddr_in.

Getting the Remote Host's Network Address

The client process can use gethostbyname to obtain the internet
address of the host and the length of that address (as the size of struct
inaddr) from /etc/hosts, NIS, or BIND. 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 node name
(null-terminated string)
Function result: pointer to struct hostent containing internet address,
NULL pointer (0) if failure occurs.
Example:
Chapter 4
Using Internet Datagram Sockets
Preparing Address Variables
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
89

Advertisement

Table of Contents
loading

Table of Contents