当前位置: 首页>>代码示例>>C#>>正文


C# NetworkInformation.NetworkInterface类代码示例

本文整理汇总了C#中System.Net.NetworkInformation.NetworkInterface的典型用法代码示例。如果您正苦于以下问题:C# NetworkInterface类的具体用法?C# NetworkInterface怎么用?C# NetworkInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetworkInterface类属于System.Net.NetworkInformation命名空间,在下文中一共展示了NetworkInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Server

 public Server (string defaultLocation, NetworkInterface networkInterface)
 {
     default_location = defaultLocation;
     network_interface_info = NetworkInterfaceInfo.GetNetworkInterfaceInfo (networkInterface);
     request_listener = new RequestListener (this);
     announcers = new Dictionary<string, Announcer> ();
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:7,代码来源:Server.cs

示例2: GetUpdateType

        public static UpdateType GetUpdateType(NetworkInterface oldInterface, NetworkInterface newInterface)
        {
            if (oldInterface.Id != newInterface.Id)
                return UpdateType.Name;

            IPInterfaceProperties oldIPProps = oldInterface.GetIPProperties();
            IPInterfaceProperties newIPProps = newInterface.GetIPProperties();

            if (HasIPChanged(oldIPProps, newIPProps))
                return UpdateType.IP;

            if (HasNetmaskChanged(oldIPProps, newIPProps))
                return UpdateType.Netmask;

            if (HasGatewayChanged(oldIPProps, newIPProps))
                return UpdateType.Gateway;

            if (HasDHCPChanged(oldIPProps, newIPProps))
                return UpdateType.DHCP;

            if (HasDNSChanged(oldIPProps, newIPProps))
                return UpdateType.DNS;

            if (!oldIPProps.Equals(newIPProps))
                return UpdateType.Other;

            return UpdateType.None;
        }
开发者ID:pjbober,项目名称:NetConfig,代码行数:28,代码来源:NetworkInterfaceComparer.cs

示例3: Client

 public Client (NetworkInterface networkInterface)
 {
     network_interface_info = NetworkInterfaceInfo.GetNetworkInterfaceInfo (networkInterface);
     service_cache = new ServiceCache (this);
     notify_listener = new NotifyListener (this);
     browsers = new Dictionary<string, Browser> ();
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:7,代码来源:Client.cs

示例4: UnicastNetworkAddressInformation

 /// <summary>
 /// Creates a new unicast network address information instance.
 /// </summary>
 /// <param name="iface">The network interface.</param>
 /// <param name="information">The address information.</param>
 public UnicastNetworkAddressInformation(NetworkInterface iface, UnicastIPAddressInformation information)
     : base(iface)
 {
     this.UnicastInformation = information;
     this.Stale = false;
     this.Selected = true;
 }
开发者ID:alexbikfalvi,项目名称:InetAnalytics,代码行数:12,代码来源:UnicastNetworkAddressInformation.cs

示例5: GetNetworkInterfaceInfo

 public static NetworkInterfaceInfo GetNetworkInterfaceInfo (NetworkInterface networkInterface)
 {
     if (networkInterface == null) {
         return new NetworkInterfaceInfo (IPAddress.Any, 0);
     }
     var properties = networkInterface.GetIPProperties ();
     var ipv4_properties = properties.GetIPv4Properties ();
     if (ipv4_properties == null) {
         throw new ArgumentException ("The specified network interface does not support IPv4.", "networkInterface");
     }
     var host_name = Dns.GetHostName ();
     foreach (var address in properties.UnicastAddresses)
     {
         string addressHostname = null;
         try
         {
             addressHostname = Dns.GetHostEntry(address.Address).HostName;
         }
         catch(SocketException)
         {
             
         }
         if (address.Address.AddressFamily == AddressFamily.InterNetwork && addressHostname == host_name) {
             return new NetworkInterfaceInfo (address.Address, ipv4_properties.Index);
         }
     }
     throw new ArgumentException (string.Format (
         "The specified network interface does not have a suitable address for the local hostname: {0}.", host_name), "networkInterface");
 }
开发者ID:automaters,项目名称:Mono.Upnp,代码行数:29,代码来源:NetworkInterfaceInfo.cs

示例6: Nic

		private Nic(NetworkInterface ni)
		{
			_isInitializing = true;
			Reload(ni);
			_isInitializing = false;
			ConnectivityCheckRequired(this);
		}
开发者ID:cssack,项目名称:CsGlobals,代码行数:7,代码来源:Nic.cs

示例7: getSentPackets

        public long getSentPackets( NetworkInterface conn )
        {
            IPInterfaceProperties properties = conn.GetIPProperties();
              IPv4InterfaceStatistics ipstat = conn.GetIPv4Statistics();

             return ipstat.BytesSent;
        }
开发者ID:kpelikhovsky,项目名称:TrafficLogger,代码行数:7,代码来源:StatCollector.cs

示例8: ChatServer

 public ChatServer(int portNumber, object networkInterface, string serverName)
 {
     this.serverName = serverName;
     this.portNumber = portNumber;
     this.networkInterface = networkInterface as NetworkInterface;
     CreateEventLog();
 }
开发者ID:notdef1ned,项目名称:voice-chat-winrt,代码行数:7,代码来源:ChatServer.cs

示例9: getReceivedTraffic

        /*
           * Get received traffic
           * returns String[] array
          */
        public long getReceivedTraffic( NetworkInterface conn )
        {
            IPInterfaceProperties properties = conn.GetIPProperties();
             IPv4InterfaceStatistics ipstat = conn.GetIPv4Statistics();

             return ipstat.BytesReceived;
        }
开发者ID:kpelikhovsky,项目名称:TrafficLogger,代码行数:11,代码来源:StatCollector.cs

示例10: NetInterface

 public NetInterface(int id, string name, NetInterfaceType type, NetworkInterface netIface)
 {
     NetshId = id;
     Name = name;
     Type = type;
     networkInterface = netIface;
 }
开发者ID:pjbober,项目名称:NetConfig,代码行数:7,代码来源:NetInterface.cs

示例11: GetGatewayAddressFromNetInterface

 public static IPAddress GetGatewayAddressFromNetInterface(NetworkInterface intf)
 {
     IPInterfaceProperties ipProps = intf.GetIPProperties();
     if (ipProps == null)
         return IPAddress.Any;
     if (ipProps.GatewayAddresses == null || ipProps.GatewayAddresses.Count == 0)
         return IPAddress.Any;
     return ipProps.GatewayAddresses[0].Address;
 }
开发者ID:JoeGilkey,项目名称:RadioLog,代码行数:9,代码来源:NetworkUtils.cs

示例12: NetworkAdapter

        public NetworkAdapter(NetworkInterface networkInterface)
        {
            _networkInterface = networkInterface;

            Thread timer = new Thread(UpdateNetworkInterface);

            timer.IsBackground = true;
            timer.Start();
        }
开发者ID:xoperator,项目名称:GoKapara,代码行数:9,代码来源:NetworkAdapter.cs

示例13: UploadSpeedEvent

 public UploadSpeedEvent(NetworkInterface inter, int sent, int seconds, int comp)
 {
     _Interface = inter;
     _Sent = sent;
     _ToBeFor = seconds;
     _Comparator = comp;
     _LastValue = inter.GetIPv4Statistics().BytesSent;
     _Name = "Upload Speed Usage Event";
 }
开发者ID:CapCalamity,项目名称:ShutdownManager,代码行数:9,代码来源:UploadSpeedEvent.cs

示例14: DownloadSpeedEvent

 public DownloadSpeedEvent(NetworkInterface inter, int received, int seconds, int comp)
 {
     _Interface = inter;
     _Received = received;
     _ToBeFor = seconds;
     _Comparator = comp;
     _LastValue = inter.GetIPv4Statistics().BytesReceived;
     _Name = "Download Speed Usage Event";
 }
开发者ID:CapCalamity,项目名称:ShutdownManager,代码行数:9,代码来源:DownloadSpeedEvent.cs

示例15: NetworkConfigModel

 public NetworkConfigModel(NetworkInterface ni)
 {
     var ip = ni.GetIPProperties();
     this.IpAddress = ip.UnicastAddresses.Count > 0 ? ip.UnicastAddresses[0].Address.ToString() : "";
     this.Gateway = ip.GatewayAddresses.Count > 0 ? ip.GatewayAddresses[0].Address.ToString() : "";
     this.Subnet = ip.UnicastAddresses.Count > 0 ? ip.UnicastAddresses[0].IPv4Mask.ToString() : "";
     this.DNSList = ip.DnsAddresses.Count > 0 ? string.Join(";", ip.DnsAddresses.Select(dn => dn.ToString())) : "";
     this.NetworkName = ni.Name;
     this.InterfaceName = ni.Description;
     this.UseDHCP = string.IsNullOrEmpty(this.IpAddress) && string.IsNullOrEmpty(this.Gateway);
 }
开发者ID:ozgend,项目名称:hive,代码行数:11,代码来源:NetworkConfigModel.cs


注:本文中的System.Net.NetworkInformation.NetworkInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。