/// <summary> /// The workhorse of the connection operation. Tries several times to /// establish a connection to the given <host, port>. If unsuccessful, /// throws an IOException indicating what went wrong. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: synchronized void doConnect(InetAddress address, int port, int timeout) throws java.io.IOException internal virtual void DoConnect(InetAddress address, int port, int timeout) { lock (this) { lock (FdLock) { if (!ClosePending && (Socket_Renamed == null || !Socket_Renamed.Bound)) { NetHooks.beforeTcpConnect(Fd, address, port); } } try { AcquireFD(); try { SocketConnect(address, port, timeout); /* socket may have been closed during poll/select */ lock (FdLock) { if (ClosePending) { throw new SocketException("Socket closed"); } } // If we have a ref. to the Socket, then sets the flags // created, bound & connected to true. // This is normally done in Socket.connect() but some // subclasses of Socket may call impl.connect() directly! if (Socket_Renamed != null) { Socket_Renamed.SetBound(); Socket_Renamed.SetConnected(); } } finally { ReleaseFD(); } } catch (IOException e) { Close(); throw e; } } }
/// <summary> /// Binds the socket to the specified address of the specified local port. </summary> /// <param name="address"> the address </param> /// <param name="lport"> the port </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected synchronized void bind(InetAddress address, int lport) throws java.io.IOException protected internal override void Bind(InetAddress address, int lport) { lock (this) { lock (FdLock) { if (!ClosePending && (Socket_Renamed == null || !Socket_Renamed.Bound)) { NetHooks.beforeTcpBind(Fd, address, lport); } } SocketBind(address, lport); if (Socket_Renamed != null) { Socket_Renamed.SetBound(); } if (ServerSocket_Renamed != null) { ServerSocket_Renamed.SetBound(); } } }