STREAMS Programming Guide

Unique Connections

With named pipes, client processes may communicate with a server process using the module connld that lets a client process get a unique, non-multiplexed connection to a server. The connld(7M) module can be pushed onto the named end of the pipe. If the named end of the pipe is then 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 open(2) and the other file descriptor is passed to the server using I_RECUFD ioctl(2). The server and the client may then communicate through a new pipe.

Figure 6-3 shows a server process that has created a pipe and pushed the connld module on the other end. The server then invokes the fattach(3C) routine to name the other end /usr/toserv.

Figure 6-3 Server Sets Up a Pipe


Figure 6-4 Processes X and Y Open /usr/toserv


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. As shown in Figure 6-4, the server process has access to three separate pipes through three file descriptors.

connld(7M) is a STREAMS-based module that has open, close, and put procedures.

When the named Stream is opened, the open routine of connld(7M) is called. The open fails if:

The open is not complete and will block until the server process has received the file descriptor using the ioctl I_RECVFD. The setting of the O_NDELAY or O_NONBLOCK flag has no impact on the open.

connld(7M) does not process messages. All messages are passed to the next object in the Stream. The read, write, put routines call putnext(9F) to send the message up or down the Stream.