How to "unbind" a socket programmatically?
- by ryan1894
1) The socket doesn't seem to unbind from the LocalEndPoint until the process ends.
2) I have tried the solutions from the other question, and also tried waiting a minute - to no avail.
3) At the moment I have tried the below to get rid of the socket and its connections:
public static void killUser(User victim)
{
LingerOption lo = new LingerOption(false, 0);
victim.connectedSocket.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.Linger, lo);
victim.connectedSocket.Shutdown(SocketShutdown.Both);
victim.connectedSocket.Disconnect(true);
victim.connectedSocket.Close();
clients.RemoveAt(victim.ID);
}
4) After a bit of googling, I can't seem to be able to unbind a port, thus if I have a sufficient amount of connecting clients, I will eventually run out of ports to listen on.