Parse() public static method

public static Parse ( string ipString ) : IPAddress
ipString string
return IPAddress
Beispiel #1
0
        //开启服务器
        public void Start(string host, int port)
        {
            //定时器
            _timer.Elapsed  += new ElapsedEventHandler(HandleMainTimer);
            _timer.AutoReset = false;
            _timer.Enabled   = true;
            //连接池
            _conns = new Conn[_maxConn];
            for (int i = 0; i < _maxConn; i++)
            {
                _conns[i] = new Conn();
            }
            //Socket
            _listenfd = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //Bind
            IPAddress  ipAdr = IPAddress.Parse(host);
            IPEndPoint ipEp  = new IPEndPoint(ipAdr, port);

            _listenfd.Bind(ipEp);
            //Listen
            _listenfd.Listen(_maxConn);
            //Accpet
            _listenfd.BeginAccept(AcceptCb, null);
            Console.WriteLine("[服务器]启动成功");
        }
        /// <summary>
        /// Determines whether the current request is on localhost.
        /// </summary>
        /// <returns>
        /// <c>true</c> if current request is localhost; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsLocalhost()
        {
            try
            {
                var hostAddress = HttpContext.Current.Request.UserHostAddress ?? string.Empty;
                var address     = IPAddress.Parse(hostAddress);
                Debug.WriteLine("IP Address of user: "******"404Handler");

                var host = Dns.GetHostEntry(Dns.GetHostName());
                Debug.WriteLine("Host Entry of local computer: " + host.HostName, "404Handler");
                return(address.Equals(IPAddress.Loopback) || (Array.IndexOf(host.AddressList, address) >= 0));
            }
            catch
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Determines whether the current request is on localhost.
        /// </summary>
        /// <returns>
        ///     <c>true</c> if current request is localhost; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsLocalhost()
        {
            bool localHost = false;

            try
            {
                IPAddress address = IPAddress.Parse(HttpContext.Current.Request.UserHostAddress);
                Debug.WriteLine("IP Address of user: "******"404Handler");

                IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
                Debug.WriteLine("Host Entry of local computer: " + host.HostName, "404Handler");
                localHost = address.Equals(IPAddress.Loopback) || (Array.IndexOf(host.AddressList, address) >= 0);
            }
            catch
            {
                // localhost is false
            }
            return(localHost);
        }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     oscClient       = new OSCClient(IPAddress.Parse(ClientIP), Port);
     currentClientIP = ClientIP;
 }