Click here to Skip to main content
14,734,133 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

How to Know whether the Client Has Crashed or not While Communicating With Server Using named Pipe.....

Updated 26-Sep-11 3:31am
Albert Holguin 26-Sep-11 11:08am
There's no way to tell that from a named pipe as Chuck has pointed out in his solution... If you need to know if a machine crashed you probably need a number of additional tests for this (for example, attempt to ping the machine).

1 solution

Depends on what you mean by "crashed".

Your ReadFile() or WriteFile() operations will end up failing (return an error indicator) and you can check GetLastError() to find out if the pipe is broken.

However, you cannot tell exactly why the pipe is no longer functional.

1) Client machine crashed (blue screen)
2) Client machine was rebooted on purpose
3) Application in the client machine crashed / threw an exception
4) Application in the client just got tired of talking and closed its pipe
5) Physical person on the client logged off and took down all applications
6) Any number of the myriad ways to lose network connectivity between the client and the server, including but not restricted to pulled cables, lightening strikes / power outages, microwave interference, sunspots, etc.

There is no single error code that will tell you any of these. Other diagnostic tools may be necessary to tell "crashed" from any of these.
Albert Holguin 26-Sep-11 11:03am
Maybe he just means how to tell if the client disappeared from the servers perspective... either way... +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900