private void CloseClientSocket() { _communicationCountersService?.CommunicationChannels.Decrement(); _log.Debug($"Closing client socket with IP {RemoteIPAddress}"); try { _log.Debug($"Trying shutdown Socket with IP {RemoteIPAddress}"); _socketReceiveAsyncEventArgs.AcceptSocket.Shutdown(SocketShutdown.Both); } catch (Exception ex) { _log.Warning($"Socket shutdown failed for IP {RemoteIPAddress}", ex); } _isSendProcessing = false; _socketReceiveAsyncEventArgs.AcceptSocket?.Close(); SocketClosedEvent?.Invoke(this, null); }
protected virtual void OnSocketClosed(USocket us, bool fromRemote) { SocketClosedEvent?.Invoke(this, new SocketCloseEventArg { Socket = us, FromRemote = fromRemote }); }