【发布时间】:2015-09-21 07:57:37
【问题描述】:
我正在使用 C# Framework 4.0 Windows 窗体。我的程序安装在服务器上。有 4 个轻客户端连接到此服务器。
当其中一个客户启动我的程序时,我如何才能获得他的 IP 地址和计算机名称
【问题讨论】:
-
IP 地址在端点属性中。我认为它在 Listener.Client 对象中。您可能必须 ping IP 地址才能获得名称的计算机名称。
标签: c#
我正在使用 C# Framework 4.0 Windows 窗体。我的程序安装在服务器上。有 4 个轻客户端连接到此服务器。
当其中一个客户启动我的程序时,我如何才能获得他的 IP 地址和计算机名称
【问题讨论】:
标签: c#
试试这个
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net; //Include this namespace
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
Console.WriteLine(hostName);
// Get the IP
string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
欲了解更多详情,请访问: http://www.c-sharpcorner.com/UploadFile/167ad2/get-ip-address-using-C-Sharp-code/
谢谢
【讨论】: