根据IP和端口号异步短时间判断服务器是否链接

/// <summary>
        /// 短时间判断是否可以连接
        /// </summary>
        /// <param name="ipe"></param>
        /// <returns></returns>
        public static bool TestConnet(IPEndPoint ipe)
        {
            bool b = false;
            var client = new TcpClient();
            try
            {
                var ar = client.BeginConnect(ipe.Address, ipe.Port, null, null);
                ar.AsyncWaitHandle.WaitOne(500);
                b = client.Connected;
                client.Close();
                return b;
            }
            catch
            {
                return b;
            }
            finally
            { client.Close(); }
        }
原文地址:https://www.cnblogs.com/lijianda/p/7260949.html