Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Address conversion with SOCKETS(POSIX)

&pagelevel(2)&pagelevel

Network addresses have to be determined and created to enable processes to communicate with each other over sockets. The SOCKETS library provides various utility functions and macros for this purpose and these are described in this chapter. All utility functions are described in detail in "SOCKETS(POSIX) user functions".

Before a client and a server can communicate with each other, the client has to determine the service on the remote host. The following address conversion stages are required to determine the service concerned:

  1. A service and a host are each assigned names for better legibility at the user program level, e.g. the service telnet on host nonet.

  2. The system converts a service name into a service number (port number) and a host name into a network address (IPv4 or IPv6 address).

  3. Using the port number and IPv4 or IPv6 address, the system determines the route to the host on which the service is provided.

It is not meaningful to use the host name to get the location, i.e. physical address of a host. Lower level network services should locate a host at the time that another host wishes to communicate with it. This method makes it possible to change the physical location of a host without affecting addressing by the communicating partner.

The following conversion functions are available:

  • host names to network addresses and vice versa

  • network names to network numbers

  • protocol names to protocol numbers

  • service names to port numbers and the relevant protocol for communicating with the server

If you wish to use one of these functions, you have to include the <netdb.h> file.

Program examples which use the conversion functions described below can be found in "Client/server model with SOCKETS(POSIX)".