- Joined
- Aug 6, 2009
- Messages
- 2,132
- Reaction score
- 429
Okay so here is my simple&small test server using asynchronious sockets.
So far it can do following:
- Handle multiple clients
- Receive messages from clients
- Send message to all clients or specific client
But here is problem. When client closes connection it starts to send bunch of null packets. How can I close socket and remove client from the list once he disconnects?
I have a check for packet lenght
And I tried adding else statement which would mean that server received null/empty packet and that would mean client for closed connection.
Now how would I properly close socket/connection with that client, cause he still sends bunch of empty packets to server?
Main.cs:
ServerSocket.cs
Client.cs
So far it can do following:
- Handle multiple clients
- Receive messages from clients
- Send message to all clients or specific client
But here is problem. When client closes connection it starts to send bunch of null packets. How can I close socket and remove client from the list once he disconnects?
I have a check for packet lenght
Code:
if (bytesReceived > 0)
{
Console.WriteLine("[" + clientIP + "](" + bytesReceived.ToString() + "): " + BitConverter.ToString(clientBuffer, 0, bytesReceived));
}
And I tried adding else statement which would mean that server received null/empty packet and that would mean client for closed connection.
Now how would I properly close socket/connection with that client, cause he still sends bunch of empty packets to server?
Main.cs:
You must be registered to see links
ServerSocket.cs
You must be registered to see links
Client.cs
You must be registered to see links