I am writing a program for reading from and writing to pipes. I found out that by using PeekNamedPipe function I can get the number of bytes which are ready to be read. But I have a question How can I wait for coming data. Can I use WaitForSingleObject function for waiting on a pipe to get data from other end of pipe. regards,
You can either use Overlapped I/O, or preferably use Completion Routines. They are both asynchronous (non-blocking), but I prefer completion routines as you register a callback that gets called when there is data to read - no need to poll for data. Check out the links and build and run through the examples. It may take a little time to understand / implement, but you will be glad you took that time to do it right when it's working well :).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With