multicast with multiple NICs in QNX 6.3

I’m porting an application from LINUX to QNX.

I need to figure out how to multicast with a specific NIC device.
Over in LINUX it’s basically finding the device index, then using that
index when doing the join. Here’s how I get the index in LINUX:

bool getiindex(int& iindex,int sock,sockaddr* sa,const char* dev)
struct ip_mreqn mreqn;
struct ifreq m_ifreq;
int i;

iindex = -1;
mreqn.imr_multiaddr = *(struct in_addr ) &(sa->sa_data[2]);
for (i = 0; i < IFNAMSIZ && dev_; ++i)
m_ifreq.ifr_name = dev;
for (; i < IFNAMSIZ; ++i)
m_ifreq.ifr_name = 0;

if (ioctl (sock, SIOCGIFINDEX, &m_ifreq))

iindex = m_ifreq.ifr_ifindex;

The chief porting problem is with the ioctl call: I find no
SIOCGIFINDEX request type for ioctl in QNX.

The function I use in LINUX for joining a multicast group on a
particular ethernet device then looks like:

bool join(int sock,sockaddr
sa,const char *ip,const char *dev)
struct ip_mreqn group;
struct sockaddr_in myaddr;
socklen_t len = sizeof(myaddr);
int iindex(0);

if( !getiindex(iindex,sock,sa,dev) )

getsockname(sock, (struct sockaddr *)&myaddr, &len);
memcpy(&group.imr_address, &myaddr.sin_addr,
group.imr_ifindex = iindex;
setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group,

I don’t know if QNX does it anything like this, but I definitely need
to find out how to accomplish the same task: How do I join a
multicast group on a specific ethernet device when more than one
device is present in the system?

Many thanks!


Edmund Rishekl <> wrote:

I’m porting an application from LINUX to QNX.

Answered in qnx.rtos.