Results 1 to 1 of 1

Thread: Qt5 QUdpSocket and setsockopt

  1. #1
    Join Date
    Jun 2011
    Posts
    23
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Qt5 QUdpSocket and setsockopt

    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
    Qt Code:
    1. error: expected primary-expression before 'char'
    2. int result = setsockopt(udpSocket->socketDescriptor(), IPPROTO_IP, IP_MULTICAST_IF, char*(&multicastInterface), sizeof(struct in_addr));
    3. ^
    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


    Qt Code:
    1. udpSocket = new QUdpSocket(this);
    2.  
    3. struct servent *serv;
    4. serv = getservbyname("data_in", "udp");
    5.  
    6. quint16 port = qFromBigEndian(uint16_t(serv->s_port));
    7.  
    8. if(udpSocket->bind(QHostAddress::AnyIPv4, port, QUdpSocket::ShareAddress) == true)
    9. {
    10. struct in_addr multicastInterface;
    11. multicastInterface.s_addr =inet_addr("230.70.10.10");
    12.  
    13. int result = setsockopt(udpSocket->socketDescriptor(), IPPROTO_IP, IP_MULTICAST_IF, char*(&multicastInterface), sizeof(struct in_addr));
    14. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by taraj; 5th September 2017 at 03:18.

Similar Threads

  1. QUdpSocket doubt
    By krsree in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2013, 08:23
  2. QUpdSocket and setsockopt()
    By bob2oneil in forum Qt Programming
    Replies: 0
    Last Post: 28th October 2011, 22:07
  3. QUdpSocket not getting responses
    By mhoover in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2009, 02:40
  4. UDP - QUdpSocket
    By denwelzie in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2008, 10:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.