best way to handle cliet disconnection

  • Thread starter Thread starter virtouso
  • Start date Start date
V

virtouso

Guest
hello my friends.

im working on a project that there is one server and it runs always and it should receive clients connection requests and handle their disconnection.

i wrote my disconnect code on clients like below:

private void button2_Click(object sender, EventArgs e)
{
server.Shutdown(SocketShutdown.Both);
server.Disconnect(true);
server.Close();
}// end of button2==disconnect

but imidiately server program crashesh and i think its obvious. because there is still a socket on client. how can i handle this kind of coding on server.

i thought to instead of disconnecting client by itself it send a string like "dis" and if server checked that name disconect that socket and remove that socket from the List.

what you think. what is the best way to behave with a client

Continue reading...
 
Back
Top