checking a pipe status
-
I've got a named pipe. One process writes to its (let's call it A) side, and the other process reads from its oposite (B) side. The process at the B side can randomly connect to and disconnect from the pipe. I'd like to prevent the A-side process from even trying to write to the pipe if the B-side process is disconnected. How can A-side process check the B-side pipe status? I have an idea of using PeekNamedPipe() with all its pointer parameters set to NULL and, when I get return value zero, interpret the result of GetLastError(), but this idea by no means seems that smart to me. Any suggestions? Is GetNamedPipeHandleState() of any use in these situations? TIA Martin
-
I've got a named pipe. One process writes to its (let's call it A) side, and the other process reads from its oposite (B) side. The process at the B side can randomly connect to and disconnect from the pipe. I'd like to prevent the A-side process from even trying to write to the pipe if the B-side process is disconnected. How can A-side process check the B-side pipe status? I have an idea of using PeekNamedPipe() with all its pointer parameters set to NULL and, when I get return value zero, interpret the result of GetLastError(), but this idea by no means seems that smart to me. Any suggestions? Is GetNamedPipeHandleState() of any use in these situations? TIA Martin
I did use PeekNamedPipe for this purpose and it worked perfectly. I use a one byte reciever buffer in the PeekNamedPipe function. You could of course use WriteFileEx with an completion Routine and wait for an error to occur. A live ping always involves sending packets and check if the reciever responds to it. There is simply no other way to check if somebody has unplugged Your network cable. PeekNamedPipe does exactly this in a transparent way without disturbing your data transfer.
-
I did use PeekNamedPipe for this purpose and it worked perfectly. I use a one byte reciever buffer in the PeekNamedPipe function. You could of course use WriteFileEx with an completion Routine and wait for an error to occur. A live ping always involves sending packets and check if the reciever responds to it. There is simply no other way to check if somebody has unplugged Your network cable. PeekNamedPipe does exactly this in a transparent way without disturbing your data transfer.
Thanks for your reply. Now I know I'm standing on the firm ground. Sometimes it's better to learn from others' successes instead of my own failures. :) Martin