internal FtpResponse Connect(int timeout, string server, int port) { CheckDisposed(); NSTrace.WriteLineVerbose("CC: -> Connect"); if (null == server) { throw new ArgumentNullException("server"); } if (port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort) { throw new ArgumentOutOfRangeException("port", "Value, specified for the port, is out of valid range."); } SetProgress(true); try { _socket.ConnectTimeout = timeout; string msg = string.Format("CC: Connecting (timeout: {0}, srv: {1}:{2})...", timeout, server, port); NSTrace.WriteLineInfo(msg); _socket.Connect(server, port); msg = string.Format("CC: Reading response..."); NSTrace.WriteLineInfo(msg); _response = _reader.ReadResponse(timeout); NSTrace.WriteLineVerbose("CC: <- Connect"); } catch (SocketException e) { CheckDisposed(); CheckTimeoutException(e); throw; } catch (Exception) { CheckDisposed(); throw; } catch { CheckDisposed(); throw; } finally { SetProgress(false); } OnResponseReceived(); return(_response); }
internal virtual void Connect(string hostName, int port) { this.CheckDisposed(); NSTrace.WriteLineInfo(string.Format("S: Resolving name '{0}'...", hostName)); IPHostEntry hostByName = GetHostByName(hostName); if (hostByName == null) { NSTrace.WriteLineInfo("S: Hostname not found, throwing exception..."); throw new SocketException(0x2af9); } NSTrace.WriteLineInfo("S: Hostname found, connecting ..."); this.Connect(ConstructEndPoint(hostByName, port)); NSTrace.WriteLineInfo("S: Connection established."); }
virtual internal void Connect(string hostName, int port) { CheckDisposed(); string msg = string.Format("S: Resolving name '{0}'...", hostName); NSTrace.WriteLineInfo(msg); IPHostEntry host = GetHostByName(hostName); if (null == host) { NSTrace.WriteLineInfo("S: Hostname not found, throwing exception..."); throw new SocketException(SockErrors.WSAHOST_NOT_FOUND); } NSTrace.WriteLineInfo("S: Hostname found, connecting ..."); Connect(ConstructEndPoint(host, port)); NSTrace.WriteLineInfo("S: Connection established."); }