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. Set socket information
Forum Updated to NodeBB v4.3 + New Features

Set socket information

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 827 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.
  • M Offline
    M Offline
    moravas
    wrote on last edited by
    #1

    Hi Folks,

    I have one UDP and one TCP socket that are instances of QTcpSocket and QUdpSocket classes. I need to copy the IP and the port information from the TCP socket into the UDP object, but I think that I cannot use the connectToHost() method because the UDP server still isn't represented. Does anybody have idea how can I do that?

    Regards,
    Norbert

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vtong
      wrote on last edited by
      #2

      Hi,
      I'm working on network communication.
      My project is writing an app that connect with our system through wifi.
      At Device end, we install a Wifi to UART to communicate with ARM MCU in our controller.
      Right now, the app can receive sensor value sent from controller.
      However, the app still doesnot send command to controller.
      I tried with TCP and UDP.
      Anyone has idea on how to send command to a MCU based system?
      Hi Moravas,
      When I used UDP, here is my code:
      while (udpSocket->hasPendingDatagrams()) {
      QByteArray datagram;
      datagram.resize(udpSocket->pendingDatagramSize());

          QHostAddress sender;
          quint16 senderPort;
      
          udpSocket->readDatagram(datagram.data(),datagram.size(), &sender, &senderPort);
      
          
      }
      

      As you can see, in readDatagram will return addr and port of the sender.
      You can use it.

      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