在C#套接字客户端应用程序中获取客户端IP地址

编程入门 行业动态 更新时间:2024-10-10 03:33:23
本文介绍了在C#套接字客户端应用程序中获取客户端IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在C#中创建套接字客户端应用程序 如何获取已连接到服务器的客户端的IP地址

I am making socket client application in C# how can i get ip address of client who has connected to server

推荐答案

从哪一方?如果你在谈论服务器,那么Socket.Accept 返回一个套接字,你可以从属性获得远程IP Socket.RemoteEndPoint。如果你想在客户端获得客户端IP,你需要在.NET 1.x中调用Dns.Resolve()或在.NET 2中调用Dns.GetHostAddresses()。 - Vit Zayko From which side? If you are talking about server then Socket.Accept returns a socket and you can get remote IP from property Socket.RemoteEndPoint. If you want to get client IP on client side you should call Dns.Resolve() in .NET 1.x or Dns.GetHostAddresses() in .NET 2. -- Vit Zayko

我想在连接的客户端服务器上获取IP地址 i得到socket.LocalEndpoint但是无法获得 socket.RemoteEndpoint i want to get ip address on server of client which is connected i am getting socket.LocalEndpoint but not able to get socket.RemoteEndpoint

我想在客户端的服务器上获取ip地址已连接 i我正在获取socket.LocalEndpoint但无法获得 socket.RemoteEndpoint i want to get ip address on server of client which is connected i am getting socket.LocalEndpoint but not able to get socket.RemoteEndpoint

更多推荐

在C#套接字客户端应用程序中获取客户端IP地址

本文发布于:2023-11-16 14:47:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605244.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   应用程序   地址   IP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!