TCP/IP Programming Manual

The #include directive contains the declaration of the sockaddr_in structure. The program
declares that the sin structure is based on the sockaddr_in structure. The socket s1 is created
by a call to the socket routine. The bind routine syntax requires that the address and port number
that you want to bind to the socket be stored in a structure based on the sockaddr_in structure.
The routine also requires that you pass a pointer to that structure (sin, in this example).
The following program excerpt shows an example for IPv6:
#include "$system.ztcpip.in6h"
..
struct sockaddr_in6 sin;
s1= socket (AF_INET6, SOCK_STREAM, 0);
sin6.sin6.family=AF_INET6;
sin6.sin6_port;
sin6.sin6_addr=in6addr_any;
bind (s1,struck sockaddr *)&sin, sizeof(sin));
sockaddr_in
This structure defines an address-port number combination that is used by many of the socket
routines. It is defined in the in.h header file.
C Declaration
#include <in6.h> struct sockaddr_in {
short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sa_data[8]; };
TAL Declaration
?NOLIST, SOURCE SOCKDEFT
STRUCT sockaddr_in (*);
BEGIN
INT sin_family;
INT sin_port;
STRUCT sin_addr(in_addr);
STRING sa_data[0:8];
END;
sin_family
is the type of address. Its value is always AF_INET because only Internet addresses are
supported.
sin_port
is the port number associated with the socket.
sin_addr
is the Internet address (based on the in_addr structure) associated with the socket.
sa_data
is not currently used. It is reserved for future use.
sockaddr_in6
This structure specifies a local or remote endpoint address to which to connect a socket. This
structure is IPv6 specific and is defined in the in6.h header file. This structure applies to NonStop
TCP/IPv6 only.
C Declaration
#include <in6.h>
78 Data Structures