繁体   English   中英

在服务器上:获取已连接客户端的IP地址

[英]On the Server: Getting IP Address of Connected Clients

我有两台计算机:服务器和客户端,当我通过以下方式在客户端计算机中请求客户端IP时

TcpClient client = new TcpClient();
client.Connect(serverip, PORTNO);
MessageBox.Show(client.Client.LocalEndPoint.ToString());

我得到:192.168.241.128:1025这是客户端IP。

但是当我在服务器上申请以下内容时:

_client = client;
_clientIP = client.Client.RemoteEndPoint.ToString();
AllClients.Add(_clientIP, this);
data = new byte[_client.ReceiveBufferSize];
_client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(_client.ReceiveBufferSize), ReceiveMessage, null);

MessageBox.Show(client.Client.RemoteEndPoint.ToString());

我得到192.168.92.1:1047这是服务器IP!

有什么问题?

有一天,发生在我身上的问题是使用vmware! 当我尝试连接到真实网络时...我获得了正确的IP尝试在真实网络中实现!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM