Programming with sockets

Supporting routines

The discussion in ``Basics'' mentions the possible need to locate and construct network addresses when using the communication facilities in a distributed environment. To aid in this task several routines have been added to the standard C run-time library. In this section we will consider the new routines provided to manipulate network addresses.

Locating a service on a remote host requires many levels of mapping before client and server may communicate. A service is assigned a name that is intended for human consumption; for example, the login server on host monet. This name, and the name of the peer host, must then be translated into network addresses that are not necessarily suitable for human consumption. Finally, the address must then be used in locating a physical location and route to the service. The specifics of these three mappings are likely to vary between network architectures. For instance, it is desirable for a network not to require hosts to be named in such a way that their physical location is known by the client host. Instead, underlying services in the network may discover the location of the host at the time a client host wishes to communicate. This ability to have hosts named independent of their location may induce overhead in connection establishment, as a discovery process must take place, but allows a host to be physically mobile without requiring it to notify its clientele of its current location.

Standard routines are provided for mapping host names to network addresses, network names to network numbers, protocol names to protocol numbers, and service names to port numbers and the appropriate protocol to use in communicating with the server process. The file netdb.h must be included when using any of these routines.

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005