Click here to Skip to main content
15,891,680 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have client server communication application running on different machines perfectly. Suppose if I disconnect the network cable at client side then I want to get one message "network cable unplugged" on server side. How can identify when the network cable was unplugged? Please send the code for identifying when the network cable is unplugged from client machine.
Posted
Updated 8-Jun-10 9:55am
v2

It's down to your server to know if the clients are connected or not, once your client has removed network cable there's no way for it to communicate that this has happened.

e.g check this article

http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-threaded-tcp-server[^]

Have a look at some 'chat' type applications that will implement this sort of functionality.
 
Share this answer
 
according to my knowledge it's not easy , but sometimes we send a probe periodically to make sure the client is alive , after trying the probe for several times if we still didn't receive a reply from the client we assume the client is no longer alive and the connection is terminated, but still this doesn't say exactly it is because of network failure,

but i think your problem can be solved using socket options in c or c++

this might help you keepalive
http://docs.hp.com/en/B2355-90136/ch03s01.html[^]
 
Share this answer
 
v2

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