0

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?

Guett31
  • 258
  • 2
  • 15
  • 1
    I don't think so, but the documentation may well be incorrect on this point. Note that `PIPE_NOWAIT` is supported only for compatibility purposes, i.e., to allow programs written decades ago to continue to function. For new code, you should be using asynchronous I/O instead. – Harry Johnston Nov 28 '16 at 02:45
  • @HarryJohnston Thank you! I was not aware that PIPE_NOWAIT is old stuff. – Guett31 Nov 28 '16 at 15:53

0 Answers0