sBoff
30th October 2012, 03:14
Hi all,
I am in a situation where there is some legacy code that broadcasts on 255.255.255.255 (this cant be changed for various reasons).
The sending device has now been updated to have two network interfaces.
We want the broadcast to be sent from the original interface, not the new one. Is there a way we can specify which interface should be used to send the broadcast? I thought binding to the original interface may solve the issue but I haven't been successful in getting it to work - should it work?
m_pDataSocket->bind(originalInterfaceIPAddress, m_DataPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
We need to specify which interface to send the broadcast from because we only want the receiver to accept data that originated from the original interface.
We use the code below and then check if the 'Sender' variable is in the acceptable subnet. The problem is we we cant control what interface the broadcast is being sent from this check fails as 'Sender' has the IP address of the senders new interface.
bytesRead = m_pDataSocket->readDatagram(ByteArray.data(), ByteArray.size(), &Sender, &SenderPort);
Long story short, is there anyway to specify which network interface a broadcast UDB packet should be sent from?
I hope this make sence,
Regards
I am in a situation where there is some legacy code that broadcasts on 255.255.255.255 (this cant be changed for various reasons).
The sending device has now been updated to have two network interfaces.
We want the broadcast to be sent from the original interface, not the new one. Is there a way we can specify which interface should be used to send the broadcast? I thought binding to the original interface may solve the issue but I haven't been successful in getting it to work - should it work?
m_pDataSocket->bind(originalInterfaceIPAddress, m_DataPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
We need to specify which interface to send the broadcast from because we only want the receiver to accept data that originated from the original interface.
We use the code below and then check if the 'Sender' variable is in the acceptable subnet. The problem is we we cant control what interface the broadcast is being sent from this check fails as 'Sender' has the IP address of the senders new interface.
bytesRead = m_pDataSocket->readDatagram(ByteArray.data(), ByteArray.size(), &Sender, &SenderPort);
Long story short, is there anyway to specify which network interface a broadcast UDB packet should be sent from?
I hope this make sence,
Regards