【发布时间】:2013-03-04 13:33:31
【问题描述】:
我正在使用UdpClient 从多播组中读取数据。
它是这样配置的:
m_udpClientReceiver = new UdpClient();
m_receivingEndPoint = new IPEndPoint(IPAddress.Any, m_port);
m_udpClientReceiver.ExclusiveAddressUse = false;
m_udpClientReceiver.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
m_udpClientReceiver.ExclusiveAddressUse = false;
m_udpClientReceiver.Client.Bind(m_receivingEndPoint);
m_udpClientReceiver.JoinMulticastGroup(m_multicastAddress, 255);
我读了它:
Byte[] data = m_udpClientReceiver.Receive(ref m_receivingEndPoint);
我有几个网卡(两个 LAN,一个 wifi),绑定在不同的子网上。我需要知道在哪个网卡(实际上是哪个 ip)上收到了请求。
我怎样才能做到这一点?
谢谢!
【问题讨论】:
-
我认为你可以在数据包数据/标题中读取它
-
?在哪里?标头将包含多播地址
-
用接收方ip地址计算的udp校验和si,所以它一定在某个地方
-
嗨,也许这可以帮助你stackoverflow.com/questions/29890/…
-
@ChristopherCabezudoRodriguez :它不适用于同一子网络上的 wifi+LAN 网络。
标签: c# networking network-programming multicast udpclient