[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Communications Programming Concepts

Sockets Interface

The kernel structure consists of three layers: the socket layer, the protocol layer, and the device layer. The socket layer supplies the interface between the subroutines and lower layers, the protocol layer contains the protocol modules used for communication, and the device layer contains the device drivers that control the network devices. Protocols and drivers are dynamically loadable. The Socket Label figure illustrates the relationship between the layers.

Figure 9-1. Socket Label. This diagram shows the client process on the left with the socket layer beneath it, and the protocol layer and device layer below. The protocol layer is between the other two layers. Corresponding layers are below the server process on the right. A U-shaped dashed line representing the network runs through all six layers and connects the server and client processes. Along this line are network drivers in the device layers and TCP/IP, which is in the protocol layers.

Figure K19120chri not displayed.

Processes communicate using the client and server model. In this model, a server process, one end point of a two-way communication path, listens to a socket. The client process, the other end of the communication path, communicates to the server process over another socket. The client process can be on another machine. The kernel maintains internal connections and routes data from client to server.

Within the socket layer, the socket data structure is the focus of activity. The system-call interface subroutines manage the activities related to a subroutine, collecting the subroutine parameters and converting program data into the format expected by second-level subroutines.

Most of the socket facilities are implemented within second-level subroutines. These second-level subroutines directly manipulate socket data structures and manage the synchronization between asynchronous activities.

Socket Interface to Network Facilities

The socket interprocess communication (IPC) facilities, illustrated by the Operating System Layer Examples figure, are layered on top of networking facilities. Data flows from an application program through the socket layer to the networking support. A protocol-related state is maintained in auxiliary data structures that are specific to the supporting protocols. The socket level passes responsibility for storage associated with transmitted data to the network level.

Figure 9-2. Operating System Layer Examples. This diagram shows three layers on the left as follows from the top: socket layer, network protocols, and network interfaces. The three layers on the right are as follows from the top: stream socket, TCP/IP protocols, and 10M-bit Ethernet. Data flows both ways between layers of the same level (for example, between the socket layer and the stream socket).

Figure L69140chri not displayed.

Some of the communication domains supported by the socket IPC facility provide access to network protocols. These protocols are implemented as a separate software layer logically below the socket software in the kernel. The kernel provides ancillary services, such as buffer management, message routing, standardized interfaces to the protocols, and interfaces to the network interface drivers for the use of the various network protocols.

User request and control output subroutines serve as the interface from the socket subroutines to the communication protocols.

Note: Socket error codes issued for network communication errors are defined as codes 57 through 81 and are in the /usr/include/sys/errno.h file.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]