如何获取客户端IP。苹果电脑。 PC名称使用wcf4(tcp / ip模式)

时间:2014-07-08 09:19:16

标签: c# wcf .net-4.0 wcf-4

我在LAN服务器上运行wcf服务,使用tcp / ip模式。 现在,当客户端发送请求连接wcf服务时,我需要获取每个客户端信息。 因为它全部在局域网上。我只需要获取客户端MAC,IP,PC名称。 有没有办法获得这些信息?感谢。

2 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

var properties = OperationContext.Current.IncomingMessageProperties;
var endpointProperty = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (endpointProperty != null)
{
    var ip = endpointProperty.Address;
}

有关OperationContext课程的详情,请查看here

答案 1 :(得分:-2)

http://msdn.microsoft.com/en-us/library/system.environment.machinename(v=vs.110).aspx代表计算机名称

Get public/external IP address?用于IP地址

MAC的

Reliable method to get machine's MAC address in C#

在发布问题之前请考虑谷歌搜索,我在2分钟内找到了这些答案。

相关问题