GetHostByName() 정적인 개인적인 메소드

static private GetHostByName ( string hostName ) : IPHostEntry
hostName string
리턴 System.Net.IPHostEntry
 internal override void Bind(SocketBase socket)
 {
     base.CheckDisposed();
     this.SetProgress(true);
     try
     {
         IPHostEntry hostByName = SocketBase.GetHostByName(base._proxyServer);
         if (hostByName == null)
         {
             throw new SocketException(0x2af9);
         }
         IPEndPoint remoteEP = SocketBase.ConstructEndPoint(hostByName, base._proxyPort);
         base._socket.Connect(remoteEP);
         this.Negotiate();
         byte[] buffer = this.PrepareBindCmd((Socket_Socks5)socket);
         base.NStream.Write(buffer, 0, buffer.Length);
         byte[] reply = this.ReadVerifyReply();
         this._localEndPoint  = this.ExtractReplyAddr(reply);
         this._remoteEndPoint = null;
     }
     finally
     {
         this.SetProgress(false);
     }
 }
 internal override void Bind(SocketBase socket)
 {
     base.CheckDisposed();
     this.SetProgress(true);
     try
     {
         IPHostEntry hostByName = SocketBase.GetHostByName(base._proxyServer);
         if (hostByName == null)
         {
             throw new SocketException(0x2af9);
         }
         IPEndPoint remoteEP = SocketBase.ConstructEndPoint(hostByName, base._proxyPort);
         base._socket.Connect(remoteEP);
         byte[] buffer = this.PrepareBindCmd((Socket_Socks4a)socket);
         base.NStream.Write(buffer, 0, buffer.Length);
         for (int i = 0; i < 8; i += base.NStream.Read(this._response, i, this._response.Length - i))
         {
         }
         this.VerifyResponse();
         this._localEndPoint  = this.ConstructBindEndPoint(remoteEP.Address);
         this._remoteEndPoint = null;
     }
     finally
     {
         this.SetProgress(false);
     }
 }
 private void Connect(EndPoint remoteEP, string hostName, int port)
 {
     base.CheckDisposed();
     this.SetProgress(true);
     try
     {
         if (remoteEP == null)
         {
             if (this._resolveHostEnabled)
             {
                 IPHostEntry host = SocketBase.GetHostByName(hostName);
                 if (host != null)
                 {
                     remoteEP = SocketBase.ConstructEndPoint(host, port);
                 }
             }
             if ((hostName == null) && (remoteEP == null))
             {
                 throw new ArgumentNullException("hostName", "The value cannot be null.");
             }
         }
         IPHostEntry hostByName = SocketBase.GetHostByName(base._proxyServer);
         if (hostByName == null)
         {
             throw new SocketException(0x2af9);
         }
         IPEndPoint point = SocketBase.ConstructEndPoint(hostByName, base._proxyPort);
         base._socket.Connect(point);
         this._localEndPoint  = null;
         this._remoteEndPoint = remoteEP;
         byte[] buffer = this.PrepareConnectCmd(remoteEP, hostName, port);
         base.NStream.Write(buffer, 0, buffer.Length);
         for (int i = 0; i < 8; i += base.NStream.Read(this._response, i, this._response.Length - i))
         {
         }
         this.VerifyResponse();
         if (remoteEP == null)
         {
             this._remotePort = port;
             this._remoteHost = hostName;
         }
     }
     finally
     {
         this.SetProgress(false);
     }
 }
예제 #4
0
        internal override void Connect(string hostName, int hostPort)
        {
            base.CheckDisposed();
            this.SetProgress(true);
            try
            {
                byte[] buffer;
                if (hostName == null)
                {
                    throw new ArgumentNullException("hostName", "The value cannot be null.");
                }
                if ((hostPort < 0) || (hostPort > 0xffff))
                {
                    throw new ArgumentOutOfRangeException("hostPort", "Value, specified for the port is out of the valid range.");
                }
                IPHostEntry hostByName = SocketBase.GetHostByName(base._proxyServer);
                if (hostByName == null)
                {
                    throw new SocketException(0x2af9);
                }
                IPEndPoint remoteEP = SocketBase.ConstructEndPoint(hostByName, base._proxyPort);
                base._socket.Connect(remoteEP);
                bool preAuthenticate = base.PreAuthenticate;
Label_0076:
                buffer = this.GetConnectCmd(hostName, hostPort, preAuthenticate);
                base.NStream.Write(buffer, 0, buffer.Length);
                ByteVector reply  = this.ReadReply();
                string     reason = null;
                int        num    = this.AnalyzeReply(reply, out reason);
                if ((num < 200) || (num > 0x12b))
                {
                    if (((0x197 != num) || preAuthenticate) || (base._proxyUser == null))
                    {
                        throw new SocketException(0x274d);
                    }
                    preAuthenticate = true;
                    goto Label_0076;
                }
            }
            finally
            {
                this.SetProgress(false);
            }
        }