Anonymous Pipes
The Windows anonymous pipes allow one-way (half-duplex), character-based IPC. Each pipe has two handles: a read handle and a write handle. The CreatePipe function is as follows.
BOOL CreatePipe (
PHANDLE phRead,
PHANDLE phWrite,
LPSECURITY_ATTRIBUTES lpsa,
DWORD cbPipe)
The pipe handles are often inheritable; the next example shows the reasons. cbPipe, the pipe byte size, is only a suggestion, and 0 specifies the default value.In order for the pipe to be used for IPC, there must be another process, and that process requires one of the pipe handles. Assume that the parent process, which calls CreatePipe, wishes to write data for a child to use. The problem, then, is to communicate the read handle (phRead) to the child. The parent achieves this by setting the child procedure's input handle in the start-up structure to *phRead.Reading a pipe read handle will block if the pipe is empty. Otherwise, the read will accept as many bytes as are in the pipe, up to the number specified in the ReadFile call. A write operation to a full pipe, which is implemented in a memory buffer, will also block.Finally, anonymous pipes are one-way. Two pipes are required for bidirectional communication.