Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

best way to handle cliet disconnection

$
0
0

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


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>