Simple messenger, server crashing, when one of the clients is killed in task manager

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello
So, Im trying to modify messenger, which i found here
http://www.csharphelp.com/2007/05/simple-messenger-developed-in-net-using-c/

The problem is, when I kill one of the clients is killed in task manager (simulating situation that internet dies or something like that), and I try to send message from another client

Here is the code
http://pastebin.com/JR5vq22i

So, what I have done: I tried to catch exception at server.SendTo, wo when it crashes I remove the client from iplist

But then another exception appears here: receive = server.ReceiveFrom(data, ref klient);
Which is kinda weird, because klient (client, I kinda mixed languages when naming :() was removed from listaip, so it shouldnt crash here...
When I catch exception here, server console starts to SPAM "Waiting for message" text. It REALLY spams console.
After that I cant send any message from another client.
The exception is "An existing connection was forcibly closed by the remote host"

Any suggestions?
If you need client code too, just tell me, I could upload whole project somewhere if needed
<br/>

View the full article
 
Back
Top