从服务器中的客户端获取IP地址

时间:2015-09-21 07:57:37

标签: c#

我正在使用C#Framework 4.0 Windows窗体。我的程序安装在服务器上。有4个轻客户端连接到此服务器。

当其中一个客户启动我的程序时,我怎样才能获得他的Ip Addreess和计算机名称

1 个答案:

答案 0 :(得分:0)

试试这个

   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/

由于