Killing the bad Winsock Connections
:confused:
I made a chat server where multiple people can connect. They all connect on the same port but through an array (so there are no conflicts). As clients connect, their names are added to a listbox. Problem is when they disconnect. Sometimes my program doesn't delete their name from the list and thinks the client is still 'alive', when infact they are gone.
The refresh for winsock.state is 10 ms (meaning it loops through all the connections on the list and deletes bad connections every 10 ms). Unfortunately, this doesn't work all the time. Some say I should ping the clients, but that would interfere with the data being sent across that port. Does anyone have any other ideas?
:confused:
Regarding the case select with Winsock...
I tried the case select for winsock:
Select Case Winsock1(ConnectedUsers(socketcheck)).State
Case 0
'Status.SimpleText = "Closed"
Case 1
'Status.SimpleText = "Open"
Case 2
'Status.SimpleText = "Listening"
Case 3
'Status.SimpleText = "ConnectionPending"
Case 4
etc...
and when there's an error, the user is removed from the listbox. this case select is executed every 10ms but some users will stay in the listbox and will not be removed even when they disconnect. any way to fix this? :-(
problem with built-in functions...
Winsock has the function error(). So if I wanted to close a connection when an error occurs, I would use that function. But the function doesn't detect an error right away. It only detects an error after i try sending data to the disconnected user. So while I'm away from the computer, my program might be adding the same people to the listbox, even though the prior connections aren't 'alive'. There must be some way to detect if an error occured.