public void CloseConnect(long handle) { if (Connects.ContainsKey(handle) == false) { return; } try { Connects[handle].Socket.Shutdown(SocketShutdown.Both); } // throws if client process has already closed catch (Exception) { } if (Connects.ContainsKey(handle) == false) { return; } Connects[handle].Socket.Close(); Connects[handle].ClientArgs.Dispose(); Connects.TryRemove(handle, out Link link); OnSocketClose?.Invoke(handle); //SocketAsyncEventArgs eventArgs = GetFreeEventArgs(); //eventArgs.UserToken = Connects[handle]; //Connects[handle].Socket.DisconnectAsync(eventArgs); }