Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinAPI Wait on a pipe for reading data

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,

like image 382
MrDoDo Avatar asked Mar 21 '26 01:03

MrDoDo


1 Answers

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 :).

like image 130
parrowdice Avatar answered Mar 23 '26 15:03

parrowdice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!