Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Verify a pipe is "alive".
I'm working on a project (SourceForge, AMaMP) that involves using pipes for communication. Currently, the connection is checked to see if it's alive by taking a peek (PeekNamedPipe) at it. I was under the impression that if it wasn't connected, checking it should return 0 and GetLastError should return 109 (The pipe has been ended). If there's data in it, it seemed that it wouldn't return 0. So I drain the pipe by reading (ReadFile) all the data from it and then peeking at it again. The return value is not 0 all the time so for some reason, even though the program at the other end has ended, the code insists that the pipe is still valid.
In short, I want a method of verifying that the connection is still alive, perhaps some way of validating the handle to the pipe?