HP OpenVMS Systems Documentation |
HP TCP/IP Services for OpenVMS
|
Previous | Contents | Index |
This section contains sample output from the preceding server and client programs. The server program makes and receives all requests on an AF_INET6 socket using sockaddr_in6 . For requests received over IPv4, sockaddr_in6 contains an IPv4-mapped IPv6 address.
The following example shows a client program running on node hostb6 and sending a request to node hosta6. The program uses an AF_INET6 socket. The node hosta6 has the IPv6 address 3ffe:1200::a00:2bff:fe97:7be0 in the Domain Name System (DNS).
$ run client.exe Enter remote host: hosta6 Initiated connection to host: hosta6.ipv6.corp.example, port: 12345 Data received: Hello, world! $ |
On the server node, the following example shows the server program invocation and the request received from the client node hostb6:
$ run server.exe Waiting for a client connection on port: 12345 Accepted connection from host: hostb6.ipv6.corp.example (3ffe:1200::a00:2bff:fe97:7be0), port: 49174 Data sent: Hello, world! $ |
The following example shows the client program running on node hostb and sending a request to node hosta. The program uses an AF_INET6 socket. The hosta node has only an IPv4 address in the DNS.
$ run client.exe Enter remote host: hosta Initiated connection to host: hosta.corp.example, port 12345 Data received: Hello, world! $ |
On the server node, the following example shows the server program invocation and the request received from the client node hostb:
$ run server.exe Waiting for a client connection on port: 12345 Accepted connection from host: hostb.corp.example (::ffff:10.10.10.251), port: 49175 Data sent: Hello, world! $ |
The following example shows the client program running on node hostb6 and sending a request to node hosta6 using its link-local address fe80::a00:2bff:fe97:7be0. The program uses an AF_INET6 socket.
$ run client.exe Enter remote host: fe80::a00:2bff:fe97:7be0 Initiated connection to host: fe80::a00:2bff:fe97:7be0, port: 12345 Data received: Hello, world! $ |
On the server node, the following example shows the server program invocation and the request received from the client node hostb6.
$ run server.exe Waiting for a client connection on port: 12345 Accepted connection from host: hosta6.ipv6.corp.example%WE0 (fe80::a00:2bff:fe97:7be0%WE0), port: 49177 Data sent: Hello, world! $ |
The following are supported IPV6 Request for Comments (RFCs):
This appendix describes deprecated library functions that were provided in previous Early Adopter Kits (EAKs). Do not use these functions if you are developing new applications. If your existing applications use these functions, see Chapter 8 for changes you should make to your code.
The following table shows the deprecated functions and their replacements:
Deprecated Function | Replacement Function |
---|---|
getipnodebyname | getaddrinfo |
getipnodebyaddr | getnameinfo |
freehostent | freeaddrinfo |
The getipnodebyname function has the following syntax:
#include <netdb.h> struct hostent *getipnodebyname( const char *name, int addr_family, int flags, int *error_num ); |
Parameters:
Description
The getipnodebyname() routine is an evolution of the gethostbyname() routine that enables name lookups in address families other than AF_INET.
The getipnodebyname() routine returns a pointer to a structure of type hostent . Its members specify data obtained from the local TCPIP$ETC:IPNODES.DAT file, TCPIP$HOSTS.DAT file or from one of the files distributed by DNS/BIND.
If multiple addresses are found, the h_addr_list field in the hostent structure contains the addresses.
The <netdb.h> header file defines the hostent structure.
If you are using DNS/BIND, the information is obtained from a name server as configured. When the name server is not running, the getipnodebyname() routine searches both the local TCPIP$ETC:IPNODES.DAT name file for IPv6 and IPv4 addresses and the hosts name file for IPv4 addresses, if the addresses not are found in the TCPIP$ETC:IPNODES.DAT file.
Table B-1 lists the flags parameters and how the processing is affected by the value of the af parameters.
Flag Value | af Value is AF_NET | af Value is AF_INET6 |
---|---|---|
0 |
Searches for A records.
If found, returns IPv4 addresses (h_length=4). If not, returns a NULL pointer. Provides backward compatibility for existing IPv4 applications. |
Searches for AAAA records.
If found, returns IPv6 records (h_length=16). If not, returns a NULL pointer. |
AI_V4MAPPED | Ignored. |
Searches for AAAA records.
If found, returns IPv6 records (h_length=16). If not, searches for A records. If A records are found, returns IPv4-mapped IPv6 addresses (h_length=16). If no A records are found, returns a NULL pointer. |
AI_ALL | AI_V4MAPPED | Ignored. |
Searches for AAAA records.
If found, returns IPv6 addresses (h_length=16). Then searches for A records. If A records are found, returns IPv4-mapped IPv6 addresses (h_length=16). If no A records are found, returns a NULL pointer. |
All flags can be used in any combination to achieve finer control of the translation process. The AI_ADDRCONFIG flag is typically used in combination with other flags to modify the search based on the source address or addresses configured on the system. Table B-2 describes how the AI_ADDRCONFIG flag works by itself.
Flag Value | af Value is AF_NET | af Value is AF_INET6 |
---|---|---|
AI_ADDRCONFIG | Searches for A records only if an IPv4 source address is configured on the system. |
Searches for AAAA records only if an IPv6 source address is configured
on the system.
Searches for A records only if an IPv4 source address is configured on the system. |
Most applications will use a combination of the AI_ADDRCONFIG and AI_V4MAPPED flags to control their search. To simplify this for the programmer, the AI_DEFAULT symbol, which is a logical OR of AI_ADDRCONFIG and AI_V4MAPPED, is defined. Table B-3 describes how AI_DEFAULT directs the search.
Flag Value | af Value is AF_NET | af Value is AF_INET6 |
---|---|---|
AI_DEFAULT |
Searches for A records only if an IPv4 source address is configured on
the system.
If found, returns IPv4 addresses (h_length=4). If not, returns a NULL pointer. |
Searches for AAAA records only if an IPv6 source address is configured
on the system.
If found, returns IPv6 records (h_length=16). If not found and if an IPv4 address is configured on the system, searches for A records. If A records are found, returns IPv4-mapped IPv6 addresses (h_length=16). If no A records are found, returns a NULL pointer. |
The hostent structure returned by the getipnodebyname function is dynamically allocated. You should free this structure and dynamic storage by using the freehostent function (see Section B.3).
Errors
If the getipnodebyname() routine call fails, error_num is set to one of the following values:
The getipnodebyaddr function has the following syntax:
#include <netdb.h> struct hostent *getipnodebyaddr( const void *src, size_t len, int af, int *error_num); |
Parameters
Description
The getipnodebyaddr() routine is an evolution of the gethostbyaddr() routine that enables address lookups in address families other than AF_INET.
The getipnodebyaddr() routine returns a pointer to a structure of type hostent . Its members specify data obtained from the local TCPIP$ETC:IPNODES.DAT file, the TCPIP$HOSTS.DAT file, or one of the files distributed by DNS/BIND.
The getipnodebyaddr() routine searches the network host database sequentially until a match with the src and af parameters occurs. The len parameter must specify the number of bytes in an Internet address. The src parameter must specify the address in network order. The af parameter can be either the constant AF_INET or AF_INET6, which specifies the IPv4 address format or the IPv6 address format, respectively. When EOF (end-of-file) is reached without a match, an error value is returned.
If the src parameter is either an IPv4-mapped IPv6 address or an IPv4-compatible IPv6 address, the routine performs the following steps:
The double colon (::) and ::1 IPv6 addresses are not considered IPv4-compatible addresses. |
If you are using DNS/BIND, the address is obtained from a name server as configured. When the name server is not running, the getipnodebyaddr() routine searches the local TCPIP$ETC:IPNODES.DAT name file for IPv6 and IPv4 addresses and the hosts name file for IPv4 addresses, if the addresses are not found in the TCPIP$ETC:IPNODES.DAT file.
The getipnodebyaddr() routine dynamically allocates the hostent structure. Use the freehostent() routine to free the allocated memory. (See Section B.3.
Errors
If the getipnodebyaddr() routine call fails, error_num is set to one of the following the values:
The freehostrent function returns hostent structures and dynamic storage to the system. You should use this function to free hostent structures and storage that were returned by getipnodebyname and getipnodebyaddr .
This function has the following syntax:
void freehostent( struct hostent *ptr ); |
The ptr parameter is a pointer to the hostent structure to be freed.
Do not use the freehostent function with hostent structures returned by gethostbyname and gethostbyaddr . |
Index | Contents |