fixed multicast updated tests
This commit is contained in:
@@ -11,8 +11,10 @@
|
||||
#include "MemoryOperationsHelper.h"
|
||||
#include "StreamString.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <poll.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
@@ -125,9 +127,17 @@ bool UDPSServer::Start() {
|
||||
if (ok) {
|
||||
tcpListener.SetBlocking(false);
|
||||
}
|
||||
// UDP data socket connected to multicast group
|
||||
// UDP data socket connected to multicast group.
|
||||
// Set IP_MULTICAST_IF so outgoing datagrams leave on the specified
|
||||
// interface rather than whichever the kernel routing table picks.
|
||||
ok &= dataSocket.Open();
|
||||
ok &= dataSocket.Join(multicastGroup.Buffer(), interface.Buffer());
|
||||
if (ok) {
|
||||
struct in_addr localIf;
|
||||
localIf.s_addr = inet_addr(interface.Buffer());
|
||||
int fd = static_cast<int>(dataSocket.GetWriteHandle());
|
||||
ok = (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
&localIf, static_cast<socklen_t>(sizeof(localIf))) == 0);
|
||||
}
|
||||
ok &= dataSocket.Connect(multicastGroup.Buffer(), dataPort);
|
||||
if (!ok) {
|
||||
REPORT_ERROR_STATIC(
|
||||
|
||||
Reference in New Issue
Block a user