Link to home
Start Free TrialLog in
Avatar of Borsec
BorsecFlag for Romania

asked on

C# Server Socket and Client Socket

I have a client-server application that communicates each other over a socket connection.
My problem is: i don't know how can i signal the server that the client is stopped.
If i use clientSocket.Close() or clientSocket.Disconnect(true), the server is informed
after 1-1.5 minutes and this is to late. On the server side i start a thread for each client that gets connected to the server and i have to know when a client is disconnected. Thanks in advance
Avatar of HugoHiasl
HugoHiasl

Did you try to send some data every 5 seconds? When the client is disconnected this should lead to an exception that can be handled.
Avatar of Borsec

ASKER

Thank you HugoHiasl, but i can't do this because the messages that are trasmitted betwen client and server are very important and don't want to create a standard message to check if the client is disconected. I want the client to notify the server that he is disconected.
Before closing send a message to server [CLOSE]. Then you can close connection at your end and client can also.

The only overhead is you need to check this message in every message which is being sent.

-Hope this helps
ASKER CERTIFIED SOLUTION
Avatar of Volox
Volox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial