According to the documentation the answer is Yes. If the named pipe is used with PIPE_NOWAIT
and PIPE_TYPE_BYTE
, WriteFile
should write the bytes to the buffer until it fills up or all the requested bytes are written.
A WriteFile operation is affected by the wait mode of a pipe handle when there is insufficient space in the pipe's buffer. With a blocking-wait handle, the write operation cannot succeed until sufficient space is created in the buffer by a thread reading from the other end of the pipe. With a nonblocking-wait handle, the write operation returns a nonzero value immediately, without writing any bytes (for a message-type pipe) or after writing as many bytes as the buffer holds (for a byte-type pipe).
But, my experiments contradict this statement. When I use WriteFile
in PIPE_NOWAIT
mode, regardless of the type mode (PIPE_TYPE_BYTE
or PIPE_TYPE_MESSAGE
), the lpNumberOfBytesWritten
is always equal to nNumberOfBytesToWrite
when the pipe buffer space is larger than nNumberOfBytesToWrite
, and equal to 0
when the pipe buffer space is smaller than nNumberOfBytesToWrite
.
I'm only expecting this behavior with PIPE_TYPE_MESSAGE
, not with PIPE_TYPE_BYTE
.
Am I misreading the documentation?