iProgrammer
New member
- Joined
- Feb 11, 2009
- Messages
- 38
I am sorry if I am bumping an old thread, but I have come across a serious problem and no luck with fixing it.
I wanted the ability to force close few clients upon particular conditions (like chat spam). I have added the following code to the MessageServer class
And in the RemoveClient method, I have added
This works perfectly fine to disconnect a particular client when the HostInfo is passed to the Close method. However, there is a problem. Whenever I try to close a connection, all the other connections from the same host are also closed.
For example, If I have three hosts connected... 192.168.1.2:2554, 192.168.1.2:2555 and 192.168.1.4:8888 and if I try to disconnect the 2nd host, the 1st host is also getting disconnected because it is from the same host, whereas the 3rd connection is working fine. This seems to be very strange. I have come across another thread at Stackoverflow mentioning the same problem, but I had no idea how to proceed.
http://stackoverflow.com/questions/...t-kills-the-connection-for-other-tcpclients-a
I wanted the ability to force close few clients upon particular conditions (like chat spam). I have added the following code to the MessageServer class
Code:
Public Sub Close(ByVal host As HostInfo)
Dim client = (From c In Me.clients.Keys _
Where Me.clients(c).Equals(host) _
Select c).First()
Me.RemoveClient(client)
End Sub
And in the RemoveClient method, I have added
Code:
client.GetStream().Close()
client.Close()
This works perfectly fine to disconnect a particular client when the HostInfo is passed to the Close method. However, there is a problem. Whenever I try to close a connection, all the other connections from the same host are also closed.
For example, If I have three hosts connected... 192.168.1.2:2554, 192.168.1.2:2555 and 192.168.1.4:8888 and if I try to disconnect the 2nd host, the 1st host is also getting disconnected because it is from the same host, whereas the 3rd connection is working fine. This seems to be very strange. I have come across another thread at Stackoverflow mentioning the same problem, but I had no idea how to proceed.
http://stackoverflow.com/questions/...t-kills-the-connection-for-other-tcpclients-a