int socketfd = m_RadarMulticastUdpSocket->socketDescriptor();
// set TTL (Time To Live)
unsigned int ttl = 30; // restricted to 38 hops
if (setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL, (const char*)&ttl, sizeof(ttl)) < 0)
{
return (1);
}
ip_mreq_source mreq;
memset(&mreq, 0, sizeof(ip_mreq));
mreq.imr_multiaddr.s_addr = inet_addr("230.0.10.1");
mreq.imr_interface.s_addr = inet_addr(qPrintable(NicAddress));
mreq.imr_sourceaddr.s_addr = ipaddress;
if (setsockopt(socketfd, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, (char*)&mreq, sizeof(mreq)) < 0)
{
return (1);
}
int socketfd = m_RadarMulticastUdpSocket->socketDescriptor();
// set TTL (Time To Live)
unsigned int ttl = 30; // restricted to 38 hops
if (setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL, (const char*)&ttl, sizeof(ttl)) < 0)
{
return (1);
}
ip_mreq_source mreq;
memset(&mreq, 0, sizeof(ip_mreq));
mreq.imr_multiaddr.s_addr = inet_addr("230.0.10.1");
mreq.imr_interface.s_addr = inet_addr(qPrintable(NicAddress));
mreq.imr_sourceaddr.s_addr = ipaddress;
if (setsockopt(socketfd, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, (char*)&mreq, sizeof(mreq)) < 0)
{
return (1);
}
To copy to clipboard, switch view to plain text mode
When I try the same thing in Qt5, it does not work. I would guess the socket descriptor changed in some way. It is not returning -1 nor am I using any QNetworkProxy. Did anything with socketDescriptor() change?
Bookmarks