Alternatives for TCP/IP connections

The following topic describes some ways to bypass port and IP address lookups for TCP/IP connections.

IP addresses for TCP/IP connections

For TCP/IP connections (both TLI and sockets), you can use the actual IP address in the hostname field instead of the host name or alias found in the hosts file. The following example shows sample IP addresses and hosts from a hosts file.
#address       hostname  alias
555.12.12.12   smoke
98.555.43.21   odyssey
12.34.56.555   knight    sales
Using the IP address for knight from the table, the following two sqlhosts entries are equivalent:
#dbservername   nettype    hostname       servicename   options
sales           ontlitcp   12.34.56.789   sales_ol   
#dbservername   nettype    hostname       servicename   options
sales           ontlitcp   knight         sales_ol   

Using an IP address might speed up connection time in some circumstances. However, because computers are usually known by their host name, using IP addresses in the host name field makes it less convenient to identify the computer with which an entry is associated.

UNIX: You can find the IP address in the net address field of the hosts file, or you can use the UNIX arp or ypmatch command.
Windows: You can configure Windows to use either of the following mechanisms to resolve a domain to an IP address:
  • Windows Internet Name Service
  • Domain Name Server

Wildcard addressing for TCP/IP connections

You can use wildcard addressing in the hostname field of the hosts file when both of the following conditions are met:
  • You are using TCP/IP connections.
  • The computer where the database server is located uses multiple network-interface cards (NICs).

If the preceding conditions are met, you can use an asterisk (*) as a wildcard in the hostname field that the database server uses. When you enter a wildcard in the hostname field, the database server can accept connections at any valid IP address on its host computer.

Each IP address is associated with a unique host name. When a computer uses multiple NICs, as in the following table, the hosts file must have an entry for each interface card. For example, the hosts file for the texas computer with two NICs might include these entries.
#address       hostname   alias
123.45.67.81   texas1
123.45.67.82   texas2

If the client application and database server share the sqlhosts information, you can specify both the wildcard and a host name or IP address in the hostname field (for example, *texas1 or *123.45.67.81). The client application ignores the wildcard and uses the host name (or IP address) to make the connection, and the database server uses the wildcard to accept a connection from any IP address.

The wildcard format allows the listen thread of the database server to wait for a client connection using the same service port number on each of the valid network-interface cards. However, waiting for connections at multiple IP addresses might require more processor time than waiting for connections with a specific host name or IP address.

The following figure shows a database server on a computer named texas that has two network-interface cards. The two client sites use different network cards to communicate with the database server.
Figure 1. Using multiple network-interface cards
This figure is described in the surrounding text.
The following examples show potential sqlhosts connectivity information for the texas_srvr database server.
#dbservername   nettype    hostname        servicename   options
texas_srvr      ontlitcp   *texas1         pd1_on
#dbservername   nettype    hostname        servicename   options
texas_srvr      ontlitcp   *123.45.67.81   pd1_on
#dbservername   nettype    hostname        servicename   options
texas_srvr      ontlitcp   *texas2         pd1_on
#dbservername   nettype    hostname        servicename   options
texas_srvr      ontlitcp   *123.45.67.82   pd1_on
#dbservername   nettype    hostname        servicename   options
texas_srvr      ontlitcp   *               pd1_on
If the connectivity information corresponds to any of the preceding lines, the texas_srvr database server can accept client connections from either of the network cards. The database server finds the wildcard in the hostname field and ignores the explicit host name.
Tip: For clarity and ease of maintenance, include a host name when you use the wildcard in the host name field (that is, use *host instead of *).

The connectivity information used by a client application must contain an explicit host name or IP address. The client applications on iowa can use any of the following host names: texas1, *texas1, 123.45.67.81, or *123.45.67.81. If there is a wildcard (*) in the hostname field, the client application ignores it.

The client application on kansas can use any of the following host names: texas2, *texas2, 123.45.67.82, or *123.45.67.82.

Port numbers for TCP/IP connections

For the TCP/IP network protocol, you can use the actual TCP listen port number in the service name field.

For example, if the port number for the sales database server in the services file is 1543, you can write an entry in the sqlhosts file as follows:
#dbservername   nettype    hostname   servicename   options
sales           ontlitcp   knight     1543

Using the actual port number might save time when you make a connection in some circumstances. However, as with the IP address in the hostname field, using the actual port number might make administration of the connectivity information less convenient.