Modifying an Existing Pipe

Two ends of the same pipe may have different read or wait modes, but CreateFile always copies the original attributes when it opens a handle for a client. Any process, however, can modify its pipe handle with SetNamedPipeHandleState.

BOOL SetNamedPipeHandleState(
   HANDLE  hNamedPipe,                 // handle of a named pipe
   LPDWORD lpdwModes,                  // read and wait mode flags
   LPDWORD lpdwMaxCollect,             // transmission buffer size
   LPDWORD lpdwCollectDataTimeout );   // max time before transmission

The first parameter is a handle returned by CreateNamedPipe or CreateFile.

The second parameter, like the fdwPipeMode parameter of CreateNamedPipe, combines flags to set several attributes at once. The lpdwModes parameter controls whether read operations use the byte or message mode and whether certain commands will block while they wait for the pipe to become available. The read mode may be PIPE_READMODE_BYTE or PIPE_READMODE_MESSAGE. (Specifying the message read mode for a pipe that was created with PIPE_TYPE_BYTE causes an error.) The read-mode pipe may be combined with either PIPE_WAIT or PIPE_NOWAIT.

The last two parameters matter only for pipes that connect with a remote machine. They control how the system buffers network transmissions. (They have no effect on pipes with the PIPE_FLAG_WRITE_THROUGH attribute, which disables network buffering.) Buffering allows the system to combine several messages into a single transmission. It holds outgoing messages in a buffer until either the buffer fills or a set time period elapses. lpdwMaxCollect sets the size of the collection buffer, and lpdwCollectDataTimeout sets the time period in milliseconds.

© 1998 SYBEX Inc. All rights reserved.