public void CloseClientSocket(SocketAsyncEventArgs e) { AsyncUserToken token = e.UserToken as AsyncUserToken; try { token.ServerSocket.Shutdown(SocketShutdown.Send); } catch (Exception) { } token.Close(); Interlocked.Decrement(ref ConnectedSockets); if (null == token.IO_Completed) { token.SetComplete(IO_Completed); token.Completed(); } if (token.PlayerName != null) { Online.Remove(token.PlayerName); token.PlayerName = null; } TokenPool.Push(token); semaphore.Release(); }