Binding a QudpSocket to multiple ports



  • I am developing an Application in Qt which will receive Unicast UDP packet from multiple senders. The senders will send unicast packet on IP and port no of receiver. Using a Timer Timeout I want to receive from multiple senders simultaneously.
    How can I Bind a single instance of QUDPSocket to many ports or Do I need to create different instance of QUDPSocket and bind to different ports.
    Please help.

    udpSocket = new QUdpSocket(this);
    udpSocket->bind(45454)


  • Qt Champions 2018

    Hi @chandradeo,

    You don't want to use a timer. You want to connect the readyRead signal to a slot as shown in the documentation.

    How can I Bind a single instance of QUDPSocket to many ports or Do I need to create different instance of QUDPSocket and bind to different ports.

    You bind a different socket to each port you want to listen on.

    Regards



  • to add to what aha_1980 wrote, binding to multiple listening ports is frivilous. There's really no good reason to tie up more than one port. It is UDP, so even if you bind to multiple ports, once the network becomes saturated you risk losing datagrams...however, unless you are flooding the thing the chance of that happening in a LAN is relatively small.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.