/// <summary> /// Constructs an empty instance. /// </summary> internal PlainSocketImpl() { if (UseDualStackImpl) { Impl = new DualStackPlainSocketImpl(ExclusiveBind); } else { Impl = new TwoStacksPlainSocketImpl(ExclusiveBind); } }
/// <summary> /// Constructs an instance with the given file descriptor. /// </summary> internal PlainSocketImpl(FileDescriptor fd) { if (UseDualStackImpl) { Impl = new DualStackPlainSocketImpl(fd, ExclusiveBind); } else { Impl = new TwoStacksPlainSocketImpl(fd, ExclusiveBind); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override protected void connect(SocketAddress endpoint, int timeout) throws java.io.IOException protected internal override void Connect(SocketAddress endpoint, int timeout) { if (endpoint == null || !(endpoint is InetSocketAddress)) { throw new IllegalArgumentException("Unsupported address type"); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final InetSocketAddress epoint = (InetSocketAddress)endpoint; InetSocketAddress epoint = (InetSocketAddress)endpoint; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String destHost = epoint.isUnresolved() ? epoint.getHostName() : epoint.getAddress().getHostAddress(); String destHost = epoint.Unresolved ? epoint.HostName : epoint.Address.HostAddress; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int destPort = epoint.getPort(); int destPort = epoint.Port; SecurityManager security = System.SecurityManager; if (security != null) { security.CheckConnect(destHost, destPort); } // Connect to the HTTP proxy server String urlString = "http://" + destHost + ":" + destPort; Socket httpSocket = PrivilegedDoTunnel(urlString, timeout); // Success! External_address = epoint; // close the original socket impl and release its descriptor Close(); // update the Sockets impl to the impl from the http Socket AbstractPlainSocketImpl psi = (AbstractPlainSocketImpl)httpSocket.Impl_Renamed; this.Socket.Impl_Renamed = psi; // best effort is made to try and reset options previously set //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'entrySet' method: Set <java.util.Map_Entry <Integer, Object> > options = OptionsMap.entrySet(); try { foreach (java.util.Map_Entry <Integer, Object> entry in options) { psi.SetOption(entry.Key, entry.Value); } } // gulp! catch (IOException) { } }
/// <summary> /// Creates a new SocketOutputStream. Can only be called /// by a Socket. This method needs to hang on to the owner Socket so /// that the fd will not be closed. </summary> /// <param name="impl"> the socket output stream inplemented </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: SocketOutputStream(AbstractPlainSocketImpl impl) throws java.io.IOException internal SocketOutputStream(AbstractPlainSocketImpl impl) : base(impl.FileDescriptor) { this.Impl = impl; Socket = impl.Socket; }