Steps in Managing Server-Client Transactions
The following sequence summarizes the typical steps in the management of
a named pipe:
- The server process creates the pipe by calling
DosCreateNPipe. DosCreateNPipe
returns a handle for the server end of the pipe. (Note that the server
uses the same handle to both read from and write to the pipe.) The pipe
is now in the disconnected state and cannot be opened by a client
process. The server process calls DosConnectNPipe
to put the pipe into a listening state.
- The pipe can now be opened by a client process.
- A client process supplies the name of the pipe
in a call to DosOpen and receives
a pipe handle in return. (The client uses the same handle to both read from
and write to the pipe.) The pipe is now in the connected state and
can be read from or written to by the client.
- The server and client processes communicate by
calling DosRead and DosWrite.
DosResetBuffer can be used to synchronize read and write dialogs. A server
process that supports a large number of clients for a local named pipe can
use DosSetNPipeSem and DosQueryNPipeSemState
to coordinate access to the pipe. Server and client processes can also
use DosTransactNPipe and DosCallNPipe
to facilitate their communication.
- After completing its transactions, the client
process calls DosClose to close
its end of the pipe. The pipe is now in the closing state and cannot
be accessed by another client.
- The server process calls DosDisConnectNPipe
to acknowledge that the client has closed its end of the pipe. The
pipe is now in the disconnected state again.
- To enable another client process to open the
pipe, the server must call DosConnectNPipe
again. This puts the pipe back into the listening state. To end its
access to the pipe, the server calls DosClose.
When all of the handles for both ends of the pipe have been closed, the
pipe is deallocated by the system.
[Back: Server-Client Communications Using Named Pipes]
[Next: Preparing a Named Pipe for a Client]