Example #1
0
 /// <summary>实例化</summary>
 /// <param name="protocol"></param>
 /// <param name="address"></param>
 /// <param name="port"></param>
 public NetUri(NetType protocol, IPAddress address, Int32 port)
 {
     Type = protocol;
     Address = address;
     Port = port;
 }
Example #2
0
 /// <summary>实例化</summary>
 /// <param name="protocol"></param>
 /// <param name="host"></param>
 /// <param name="port"></param>
 public NetUri(NetType protocol, String host, Int32 port)
 {
     Type = protocol;
     Host = host;
     Port = port;
 }
Example #3
0
 /// <summary>实例化</summary>
 /// <param name="protocol"></param>
 /// <param name="endpoint"></param>
 public NetUri(NetType protocol, IPEndPoint endpoint)
 {
     Type = protocol;
     EndPoint = endpoint;
 }
Example #4
0
 /// <summary>在指定协议和本地端口上执行查询</summary>
 /// <param name="protocol"></param>
 /// <param name="port"></param>
 /// <returns></returns>
 public StunClient(NetType protocol, Int32 port)
 {
     ProtocolType = protocol;
     Port = port;
 }
Example #5
0
 /// <summary>在指定协议上执行查询</summary>
 /// <param name="protocol"></param>
 /// <returns></returns>
 public StunClient(NetType protocol) : this(protocol, 0) { }
Example #6
0
        /// <summary>指定地址的指定端口是否已被使用,似乎没办法判断IPv6地址</summary>
        /// <param name="protocol"></param>
        /// <param name="address"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public static Boolean CheckPort(this IPAddress address, NetType protocol, Int32 port)
        {
            var gp = IPGlobalProperties.GetIPGlobalProperties();

            IPEndPoint[] eps = null;
            switch (protocol)
            {
                case NetType.Tcp:
                    eps = gp.GetActiveTcpListeners();
                    break;
                case NetType.Udp:
                    eps = gp.GetActiveUdpListeners();
                    break;
                default:
                    return false;
            }

            foreach (var item in eps)
            {
                // 先比较端口,性能更好
                if (item.Port == port && item.Address.Equals(address)) return true;
            }

            return false;
        }
 private UIPanel GetPage(NetType netType)
 {
     return _netTypePages[(int)netType];
 }