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. How can I associate the udp or tcp socket with the interface?
QtWS25 Last Chance

How can I associate the udp or tcp socket with the interface?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 325 Views
  • 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.
  • R Offline
    R Offline
    ruzgarin_oglu
    wrote on last edited by
    #1

    Folks,
    How can I connect the udp and tcp socket to an interface. For example, there is a wifi and an ethernet controller on the computer. Can I send and receive data to the network by selecting the socket I created, wifi or ethernet adapter?

    I want to show the controllers on a combobox. Whatever choice does the user make, create the socket on it and send and receive data?

    Thank you very much for your help.

    Happy codings,

    Thank you

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean bind the socket ?

      Isn't the first parameter what you are looking for ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        if you are talking about the physical interface (by name), that is platform dependent. The normal and accepted way of doing socket programming is by address and the system routing tables choose the correct interface based on that information.

        1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          Do you mean bind the socket ?

          Isn't the first parameter what you are looking for ?

          R Offline
          R Offline
          ruzgarin_oglu
          wrote on last edited by
          #4

          @SGaist said in How can I associate the udp or tcp socket with the interface?:

          Hi,

          Do you mean bind the socket ?

          Isn't the first parameter what you are looking for ?

          QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();
                 foreach (QNetworkInterface iface, list)
                 {
                     ui->comboBox->addItem(iface.humanReadableName());
                  }
          

          I added to the combobox element I listed in the code I shared above and created the adapter constructor that I selected in socket-> QUdpSocket (); bind to the object. I looked at what you said but I could not understand unfortunately: /

          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