如何检测网络中的设备 [英] How to detect devices in network

查看:72
本文介绍了如何检测网络中的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在连接网络中的某些嵌入式设备.有什么方法可以找到设备的IP并进行标识.我们使用Windows 7和WPF C#.

We are connecting some embedded devices in a network. is there any way to find the devices IP and identify them. We work with Windows 7 and WPF C#.

在设备上运行服务(例如打印机),然后在PC上运行该服务.

Running a service (like a printer) on the device, and on the PC just lookup for the service.

IP配置是自动的.要重点解决的问题是如何告诉PC网络中的哪个IP(或者在这个花瓶中只有一个直接连接)属于该设备(身份).

The IP configuration is automatic. The problem to focus is how to tell the PC which IP in the network (or a direct connection in this vase there would only be one) belongs to the device (identity).

ZeroConf怎么样?我是网络域的新手

How about ZeroConf? I am new to network domain

推荐答案

在以下代码中,它将告诉我们如何使用c#检索基本的网络设备信息,例如网络ID,网络名称和描述.

In the following code, it will tell us how to retrieve basic network device information such as network id, network name and description using c#.

要制作此程序,我们需要导入 System.Net.NetworkInformation 命名空间.

To make this program we need to import the System.Net.NetworkInformation namespace.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Net.NetworkInformation;

namespace NetworkInformationDemo1

{

    class Program

    {

        static void Main(string[] args)

        {

            //Retrive all network interface using GetAllNetworkInterface() method off NetworkInterface class.

            NetworkInterface [] niArr = NetworkInterface.GetAllNetworkInterfaces();



            Console.WriteLine("Retriving basic information of network.\n\n");

            //Display all information of NetworkInterface using foreach loop.

            foreach(NetworkInterface tempNetworkInterface in niArr)

            {

                Console.WriteLine("Network Discription  :  " + tempNetworkInterface.Description);

                Console.WriteLine("Network ID  :  " + tempNetworkInterface.Id);

                Console.WriteLine("Network Name  :  " + tempNetworkInterface.Name);

                Console.WriteLine("Network interface type  :  " + tempNetworkInterface.NetworkInterfaceType.ToString());

                Console.WriteLine("Network Operational Status   :   " + tempNetworkInterface.OperationalStatus.ToString());

                Console.WriteLine("Network Spped   :   " + tempNetworkInterface.Speed);

                Console.WriteLine("Support Multicast   :   " + tempNetworkInterface.SupportsMulticast);

                Console.WriteLine();

            }



        }

    }

}

最好的问候,
彭爱美

Best Regards,
Amy Peng


这篇关于如何检测网络中的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆