我的代码看起来像这样
IPEndPoint ipendpoint = new IPEndPoint(IPAddress.Any, 0);
UdpClient client = new UdpClient(25001, AddressFamily.InterNetwork);
byte[] recv = client.Receive(ref ipendpoint);
我使用pc1发送广播,而pc2使用此代码在同一网络中,从而接收到pc1已发送的消息。pc2监听每个网络接口(因为IPAdress.Any),这是一件好事,因为pc2可以有多个网络接口。现在我想知道这条消息实际上是从哪个网络接口/IP传入的。有没有可能检索到这些信息?
我已经尝试过调试,但似乎没有一个对象具有我需要的信息。
发布于 2014-04-20 19:56:07
客户端发送数据后,您可以查看以下内容:
ipendpoint.Address
ipendpoint.Port
获取ip和端口。
https://stackoverflow.com/questions/23181363
复制相似问题