【问题标题】:get ip address from client in server从服务器中的客户端获取IP地址
【发布时间】:2015-09-21 07:57:37
【问题描述】:

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

当其中一个客户启动我的程序时,我如何才能获得他的 IP 地址和计算机名称

【问题讨论】:

  • IP 地址在端点属性中。我认为它在 Listener.Client 对象中。您可能必须 ping IP 地址才能获得名称的计算机名称。

标签: c#


【解决方案1】:

试试这个

   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/

谢谢

【讨论】:

  • 我使用 RDP 连接到终端服务器。我会得到终端服务器的IP,而不是连接用户的IP。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-01
  • 2013-12-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-14
相关资源
最近更新 更多