【问题标题】:Getting names and IP addresses of the computers over LAN通过 LAN 获取计算机的名称和 IP 地址
【发布时间】:2010-11-23 17:25:56
【问题描述】:

如何使用 Vb.Net 代码知道哪些计算机连接到 LAN(名称和 IP 地址)? 谢谢 福尔坎

【问题讨论】:

标签: vb.net


【解决方案1】:

据我所知,这是不可能的,我知道您可以检索有关主机的数据,但不能检索 LAN。如果它是windows Server 中的DHCP Server 或XP 中的ICS,则可能是可能的。 提供的最佳解决方案是 ping 本地子网中的所有主机。类似于 ping 192.168.0-255.0-255。

【讨论】:

    【解决方案2】:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        TcpClient tcpclnt;
    
        private void Form1_Load(object sender, EventArgs e)
        {
            String hostname = Dns.GetHostName();
            MessageBox.Show(hostname);
            IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
    
            //IPHostEntry myipaddlist = Dns.GetHostByName(hostname);
          foreach(IPAddress ips in myipaddlist.AddressList)
            {
                MessageBox.Show(ipa.ToString());
            }
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                tcpclnt = new TcpClient();
                MessageBox.Show("connecting");
                tcpclnt.Connect("ur ipadress", 8001);
                label1.Text = "connected";
            }
            catch (Exception ex)
            {
                MessageBox.Show("error" + ex.StackTrace);
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2017-10-25
      • 2011-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 1970-01-01
      • 2014-08-08
      • 1970-01-01
      相关资源
      最近更新 更多