|
-
Nov 3rd, 2013, 05:18 AM
#15
Member
Re: [VB2008/.NET 3.5] Asynchronous TcpListener & TcpClient
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
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/9...r-tcpclients-a
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|