Important: Please read the Qt Code of Conduct -

Multiple udp sockets bound to the same ip address

  • Hi,
    i am having some trouble when binding two udp sockets on the same ip address, even thought i am using the ShareAddress flag. Since i did not find my mistake, i created a simple test program only including the Qt multicast receiver example code. But when i run the example programm twice, the second one also fails to bind to the socket with the error message "The bound address is already in use". Since the first one binds without any problems, there can not be any other applications which are already blocking the address. So my question is: is this intended and i am just misunderstanding the ShareAddress flag? If so, is there another way to use SO_REUSEADDR via Qt?
    I am using a windows 8.1 machine and qt 5.11.1.
    Thanks for the help and sorry for my english :)

  • @xBlue reminds you that the docs state ShareAddress has no effect under Windows. You need to use QUdpSocket::ReuseAddressHint instead.

  • @JonB
    Ah ok, i already saw that post. But since the Qt documentation on the QAbstractSocket::DefaultForPlatform flag says: "[...], and on Windows, its equivalent to ShareAddress." i assumed that ShareAddress has no effect under windows because it is the default setting. Thanks for your answer :)

Log in to reply