fixed multicast updated tests
This commit is contained in:
@@ -111,6 +111,7 @@ public:
|
||||
* - ServerAddr (char*) Server IPv4 address. Required.
|
||||
* - Port (uint16) Server UDP port (unicast) or TCP listen port (multicast). Required.
|
||||
* - MulticastGroup (char*) IPv4 multicast address; presence enables multicast mode.
|
||||
* - Interface (char*) Network interface for multicast join (e.g. "lo"). Required when MulticastGroup is set.
|
||||
* - DataPort (uint16) UDP multicast data port (defaults to Port+1).
|
||||
* - SilenceTimeout (uint32) Seconds of no data before reconnect. Default 5.
|
||||
* - ReconnectDelay (uint32) Seconds to wait between reconnect attempts. Default 2.
|
||||
|
||||
@@ -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