Results 1 to 1 of 1

Thread: QUpdSocket and setsockopt()

  1. #1
    Join Date
    Nov 2010
    Posts
    122
    Thanks
    62
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QUpdSocket and setsockopt()

    I need to set the DSCP fields for UDP frames transmitted using a QUdpSocket. This socket will transmit to a range of IP addresses, and is not bound to a particular port.

    I need to get the socket descriptor for the socket in a cross platform manner (although I can use conditional compilation)

    The problem is, the socketDescriptor() API returns -1 unless the socket is connected. If I bind to any port as shown, the ::setsockopt() API continues to fail

    Here is my code segment. Anybody have any ideas or tried to do similar things?

    Qt Code:
    1. // Create thread local storage
    2. m_udpTxSocket = new QUdpSocket();
    3.  
    4. // Bind to any socket
    5. m_updTxSocket->bind());
    6.  
    7. // Set DSCP field of socket to high priority setting
    8. DWORD DSCPValue = 0x07;
    9. if (::setsockopt(m_udpTxSocket->socketDescriptor(), // Socket descriptor
    10. IPPROTO_IP, // Socket level
    11. IP_TOS, // Socket option (type of service)
    12. (char *)&DSCPValue, // Option value buffer
    13. sizeof(DWORD)))
    14. {
    15. FILE_LOG(logERROR) << "TDMA: failed to set transmit socket DSCP value";
    16. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by bob2oneil; 28th October 2011 at 21:16.

Similar Threads

  1. To thread QUdpSocket or to not thread QUpdSocket
    By bob2oneil in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2011, 15:07

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.