Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Binding a QudpSocket to multiple ports
Forum Updated to NodeBB v4.3 + New Features

Binding a QudpSocket to multiple ports

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chandradeo
    wrote on last edited by
    #1

    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)

    aha_1980A 1 Reply Last reply
    0
    • C chandradeo

      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)

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved