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. Sending UDP packets and QUdpSocket::writeDatagram
Forum Updated to NodeBB v4.3 + New Features

Sending UDP packets and QUdpSocket::writeDatagram

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 9.1k 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.
  • J Offline
    J Offline
    jrisaacs
    wrote on last edited by
    #1

    Here is a snippet of code that I am using send a UDP packet. All works fine as long as the destination IP address is active. If the IP address is not active/reachable I see ARP 'who has a.b.c.d'. With UDP being connectionless I would not expect this behavior. Any comments or suggestions are welcome.

    60 4.562357000 DellEsgP_e1:83:f2 Broadcast ARP 42 Who has 192.168.1.119? Tell 192.168.1.123
    Thanks,


    txSocket = new QUdpSocket(this); //create UDP socket to send to

    txPacket.clear();
    txDatagram.clear();

    // Build a packet to send
    txPacket.append("This is a test");
    txPacket.append(" ");

    //Create the datagram
    txDatagram = txPacket.toUtf8(); //convert string to datagram

    //Send the datagram

    txSocket->writeDatagram(txDatagram.data(), txDatagram.size(), QHostAddress("192.168.1.118"), 1000);

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      this is the correct behaviour.

      ARP means (Address Resolution Protocol); when a destination address couldn’t be resolved by ARP, the UDP packet isn’t sent. In this way the network isn’t full of no-destination packets.

      UPD is a connectionless protocol, so if the destination is resolved the packet is sent regardless if there is someone ready to recevie it..

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jrisaacs
        wrote on last edited by
        #3

        Thanks, for the reminder an layer 2 behavior.

        Jay

        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