BytesRoad.Net.Sockets.Socket_Socks4.Connect C# (CSharp) Метод

Connect() приватный Метод

private Connect ( EndPoint remoteEP ) : void
remoteEP System.Net.EndPoint
Результат void
        override internal void Connect(EndPoint remoteEP)
        {
            CheckDisposed();
            SetProgress(true);
            try
            {
                //------------------------------------
                // Get end point for the proxy server
                //
                IPHostEntry  proxyEntry = GetHostByName(_proxyServer);
                if(null == proxyEntry)

                    // throw new HostNotFoundException("Unable to resolve proxy name.");
                    throw new SocketException(SockErrors.WSAHOST_NOT_FOUND);

                IPEndPoint proxyEndPoint = ConstructEndPoint(proxyEntry, _proxyPort);

                //------------------------------------------
                // Connect to proxy server
                //
                _socket.Connect(proxyEndPoint);

                _localEndPoint = null; // CONNECT command doesn't provide us with local end point
                _remoteEndPoint = remoteEP;

                //------------------------------------------
                // Send CONNECT command
                //
                byte[] cmd = PrepareConnectCmd(remoteEP);
                NStream.Write(cmd, 0, cmd.Length);

                //------------------------------------------
                // Read the response from proxy the server. 
                //
                int read = 0;
                while(read < 8)
                {
                    read += NStream.Read(
                        _response, 
                        read, 
                        _response.Length - read);
                }

                VerifyResponse();
            }
            finally
            {
                SetProgress(false);
            }
        }