开发者

C++ Pipe ReadFile function set timeout in Windows XP

开发者 https://www.devze.com 2023-04-04 16:10 出处:网络
Is there a way to perform ReadFile with timeout in Windows XP? If not, is there a way to break the pipe from oth开发者_StackOverflow社区er thread?Set up an asynchronous ReadFile using Overlapped I/O.

Is there a way to perform ReadFile with timeout in Windows XP?

If not, is there a way to break the pipe from oth开发者_StackOverflow社区er thread?


Set up an asynchronous ReadFile using Overlapped I/O. You can then use CancelIOEx to cancel the read at any time.


Assuming you're talking about a named pipe, the usual way is to do an overlapped read, and specify a timeout when you call WaitForSingleObject (or WaitForMultipleObjects). When/if the timeout expires, the wait will return WAIT_TIMEOUT instead of WAIT_OBJECT_0.

0

精彩评论

暂无评论...
验证码 换一张
取 消