Examples: Using the spawn() API to create child processes

The server example shows how a server program can use the spawn() API to create a child process that inherits the socket descriptor from the parent. The server job waits for an incoming connection, and then calls spawn() to create children jobs to handle the incoming connection. The attributes that are inherited by the child with the spawn() function include the following items:

The following figure illustrates how the server, worker, and client jobs interact when the spawn() server design is used.

Server, worker, and client job interaction when the spawn() server design is used

For more information, go to the spawn() function details in the Sockets APIs .

The worker example contains the code for the worker job that is created by spawn(). The worker job receives a data buffer from the client job and echos it back.


[ Information Center Home Page | Feedback ] [ Legal | AS/400 Glossary ]