public override string ToString() => Network.AddrToString(_proxy == null ? _addr : _proxy.GetAddress());
public int Initialize(ref ArraySegment <byte> readBuffer, IList <ArraySegment <byte> > writeBuffer) { if (!_isConnected) { int status = _delegate.Initialize(ref readBuffer, writeBuffer); if (status != SocketOperation.None) { return(status); } _isConnected = true; } Socket?fd = _delegate.Fd(); Debug.Assert(fd != null); Network.SetBlock(fd, true); // SSL requires a blocking socket // // For timeouts to work properly, we need to receive/send // the data in several chunks. Otherwise, we would only be // notified when all the data is received/written. The // connection timeout could easily be triggered when // receiving/sending large messages. // _maxSendPacketSize = Math.Max(512, Network.GetSendBufferSize(fd)); _maxRecvPacketSize = Math.Max(512, Network.GetRecvBufferSize(fd)); if (_sslStream == null) { try { _sslStream = new SslStream( new NetworkStream(fd, false), false, _engine.RemoteCertificateValidationCallback ?? RemoteCertificateValidationCallback, _engine.CertificateSelectionCallback ?? CertificateSelectionCallback); } catch (IOException ex) { if (Network.ConnectionLost(ex)) { throw new ConnectionLostException(ex); } else { throw new TransportException(ex); } } return(SocketOperation.Connect); } Debug.Assert(_sslStream.IsAuthenticated); _authenticated = true; _cipher = _sslStream.CipherAlgorithm.ToString(); _engine.VerifyPeer((SslConnectionInfo)GetInfo(), ToString()); if (_engine.SecurityTraceLevel >= 1) { _engine.TraceStream(_sslStream, ToString()); } return(SocketOperation.None); }