With named pipes, client processes may communicate with a server process by using a module called connld that enables a client process to gain a unique, non-multiplexed connection to a server. The connld module can be pushed onto the named end of the pipe. If connld is pushed on the named end of the pipe and that end is opened by a client, a new pipe is created. One file descriptor for the new pipe is passed back to a client (named Stream) as the file descriptor from the open call and the other file descriptor is passed to the server. The server and the client may now communicate through a new pipe.
``Server sets up a pipe'' illustrates a server process that has created a pipe and pushed the connld module on the other end. The server then invokes the fattach routine to name the other end /usr/toserv.
Server sets up a pipe
When process X (procx) opens /usr/toserv, it gains a unique connection to the server process that was at one end of the original STREAMS-based pipe. When process Y (procy) does the same, it also gains a unique connection to the server. ``Processes X and Y open /usr/toserv'' shows that the server process has access to three separate STREAMS-based pipes using three file descriptors.
connld is a STREAMS-based module that has an open, close, and put procedure. connld is opened when the module is pushed onto the pipe for the first time and whenever the named end of the pipe is opened. The connld module distinguishes between these two opens with the q_ptr field of its read queue. On the first open, this field is set to 1 and the routine returns without further processing. On later opens, the field is checked for 1 or 0. If the 1 is present, the connld module creates a pipe and sends the file descriptor to a client and a server. When the named Stream is opened, the open routine of connld is called. The connld open fails if
The setting of the O_NDELAY or O_NONBLOCK flag has no affect on the open.
The connld module does not process messages. All messages are passed to the next object in the Stream. The read and write put routines call putnext to send the message up or down the Stream.
Processes X and Y open /usr/toserv