Hi
I have the following code to set up a QUdpSocket that i wish to apply a setsockopt to be able to IPPROTO_IP and IP_MULTICAST_IF. Code will not compile on the setsockopt call with the following error
error: expected primary-expression before 'char'
int result = setsockopt(udpSocket->socketDescriptor(), IPPROTO_IP, IP_MULTICAST_IF, char*(&multicastInterface), sizeof(struct in_addr));
^
error: expected primary-expression before 'char'
int result = setsockopt(udpSocket->socketDescriptor(), IPPROTO_IP, IP_MULTICAST_IF, char*(&multicastInterface), sizeof(struct in_addr));
^
To copy to clipboard, switch view to plain text mode
Can I not do a setsockopt on the socketdescriptor of a QUdpSocket, or have I made another basic C mistake that I can't see? Or to do this do I just to create a C socket and not use QUdpSocket - or can I link them together somehow??
My reason for needing to try this is I have a problem similar to this post
https://serverfault.com/questions/81...ple-interfaces
Thanks!
Tara
struct servent *serv;
serv = getservbyname("data_in", "udp");
quint16 port = qFromBigEndian(uint16_t(serv->s_port));
{
struct in_addr multicastInterface;
multicastInterface.s_addr =inet_addr("230.70.10.10");
int result = setsockopt(udpSocket->socketDescriptor(), IPPROTO_IP, IP_MULTICAST_IF, char*(&multicastInterface), sizeof(struct in_addr));
}
udpSocket = new QUdpSocket(this);
struct servent *serv;
serv = getservbyname("data_in", "udp");
quint16 port = qFromBigEndian(uint16_t(serv->s_port));
if(udpSocket->bind(QHostAddress::AnyIPv4, port, QUdpSocket::ShareAddress) == true)
{
struct in_addr multicastInterface;
multicastInterface.s_addr =inet_addr("230.70.10.10");
int result = setsockopt(udpSocket->socketDescriptor(), IPPROTO_IP, IP_MULTICAST_IF, char*(&multicastInterface), sizeof(struct in_addr));
}
To copy to clipboard, switch view to plain text mode
Bookmarks