0

I know the differences between PIPE_WAIT and PIPE_NOWAIT modes when a named pipe works synchronously. The documentation is very clear about it.

However, it does not say anything about those differences when a named pipe works asynchronously (with FILE_FLAG_OVERLAPPED). I could not find any difference from my experiments. Therefore, I assume that specifying PIPE_WAIT or PIPE_NOWAIT makes no difference in this case. Is that correct?

Guett31
  • 258
  • 2
  • 15
  • 2
    It determines whether ReadFile() will block. Since it *never* blocks when you use overlapped I/O it does not matter. – Hans Passant Dec 01 '16 at 06:43

1 Answers1

0

No, there is a difference. If you use asynchronous ReadFile against PIPE_WAIT pipe, and there is no data in the pipe yet, it will return ERROR_IO_PENDING and I/O request will be completed when data becomes available. If pipe is in the PIPE_NO_WAIT mode, ReadFile returns ERROR_NO_DATA and I/O request completes immediately.

Ari0nhh
  • 5,720
  • 3
  • 28
  • 33
  • Are you sure? This is one of the cases I tested. It returned FALSE with err code ERROR_IO_PENDING against both PIPE_WAIT and PIPE_NO_WAIT. – Guett31 Dec 01 '16 at 07:58
  • 1
    Since you're not supposed to use `PIPE_NO_WAIT` and `FILE_FLAG_OVERLAPPED` together, the result may very well depend on which version of Windows you're running. (Or, for that matter, on the phase of the moon.) The fact that you're seeing different outcomes is unsurprising. – Harry Johnston Dec 01 '16 at 21:09