public void Close() { if (SslStream != null) { SslStream.Close(); // Closing the stream also closes the socket. SslStream = null; } _delegate.Close(); }
public void Close() { if (SslStream != null) { SslStream.Close(); SslStream = null; } _delegate.Close(); }
private Connection CreateConnection(ITransceiver transceiver, ConnectorInfo ci) { lock (this) { Debug.Assert(_pending.ContainsKey(ci.Connector) && transceiver != null); // // Create and add the connection to the connection map. Adding the connection to the map // is necessary to support the interruption of the connection initialization and validation // in case the communicator is destroyed. // Connection connection; try { if (_destroyed) { throw new CommunicatorDestroyedException(); } connection = new Connection(_communicator, _monitor, transceiver, ci.Connector, ci.Endpoint.NewCompressionFlag(false), null); } catch (System.Exception) { try { transceiver.Close(); } catch (System.Exception) { // Ignore } throw; } _connections.Add(ci.Connector, connection); _connectionsByEndpoint.Add(connection.Endpoint, connection); _connectionsByEndpoint.Add(connection.Endpoint.NewCompressionFlag(true), connection); return(connection); } }
public IncomingConnectionFactory(ObjectAdapter adapter, Endpoint endpoint, Endpoint?publish, ACMConfig acmConfig) { _communicator = adapter.Communicator; _endpoint = endpoint; _publishedEndpoint = publish; _adapter = adapter; _warn = _communicator.GetPropertyAsBool("Ice.Warn.Connections") ?? false; _monitor = new FactoryACMMonitor(_communicator, acmConfig); if (_communicator.OverrideTimeout != null) { _endpoint = _endpoint.NewTimeout(_communicator.OverrideTimeout.Value); } if (_communicator.OverrideCompress != null) { _endpoint = _endpoint.NewCompressionFlag(_communicator.OverrideCompress.Value); } try { _transceiver = _endpoint.GetTransceiver(); if (_transceiver != null) { if (_communicator.TraceLevels.Network >= 2) { _communicator.Logger.Trace(_communicator.TraceLevels.NetworkCat, $"attempting to bind to {_endpoint.Name} socket\n{_transceiver}"); } _endpoint = _transceiver.Bind(); var connection = new Connection(_communicator, null, _transceiver, null, _endpoint, _adapter); _ = connection.StartAsync(); _connections.Add(connection); } else { _acceptor = _endpoint.GetAcceptor(_adapter !.Name); if (_communicator.TraceLevels.Network >= 2) { _communicator.Logger.Trace(_communicator.TraceLevels.NetworkCat, $"attempting to bind to {_endpoint.Name} socket {_acceptor}"); } _endpoint = _acceptor !.Listen(); if (_communicator.TraceLevels.Network >= 1) { _communicator.Logger.Trace(_communicator.TraceLevels.NetworkCat, $"listening for {_endpoint.Name} connections\n{_acceptor!.ToDetailedString()}"); } } } catch (System.Exception) { // // Clean up. // try { _transceiver?.Close(); _acceptor?.Close(); } catch (System.Exception) { // Ignore } _monitor.Destroy(); _connections.Clear(); throw; } }