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. Can not send udp packet using writeDatagram

Can not send udp packet using writeDatagram

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

    Hi,

    I have a small udp sending and receiving program to test the communcation with remote server.
    after I ran it in qt ceator,I can not get the response from server ,and I can not capture the packet sent by client using wireshark even though the bind and writeDatagram function works fine.

    here is the code:
    https://drive.google.com/open?id=0Bychq2mXjGSOMVAzOVJVZERtdmc

    can anyone download this program and try to run it using QT ceator,and then help me figure out the issue.

    Thanks ahead.

    jsulmJ 1 Reply Last reply
    0
    • J Jeffson

      Hi,

      I have a small udp sending and receiving program to test the communcation with remote server.
      after I ran it in qt ceator,I can not get the response from server ,and I can not capture the packet sent by client using wireshark even though the bind and writeDatagram function works fine.

      here is the code:
      https://drive.google.com/open?id=0Bychq2mXjGSOMVAzOVJVZERtdmc

      can anyone download this program and try to run it using QT ceator,and then help me figure out the issue.

      Thanks ahead.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Jeffson I tested: writeDatagram does not work: it returns -1 and error() returns QAbstractSocket::NetworkError

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on last edited by Paul Colby
        #3

        Just at a glance, I think you might need to replace QHostAddress::LocalHost with QHostAddress::AnyIPv4 when you bind the socket?

        edit: Yep, just made that one change and it worked for me. Cheers :)

        J 1 Reply Last reply
        2
        • Paul ColbyP Paul Colby

          Just at a glance, I think you might need to replace QHostAddress::LocalHost with QHostAddress::AnyIPv4 when you bind the socket?

          edit: Yep, just made that one change and it worked for me. Cheers :)

          J Offline
          J Offline
          Jeffson
          wrote on last edited by
          #4

          @Paul-Colby wow,you can get the server reply?what is your environment?

          Paul ColbyP 1 Reply Last reply
          0
          • J Jeffson

            @Paul-Colby wow,you can get the server reply?what is your environment?

            Paul ColbyP Offline
            Paul ColbyP Offline
            Paul Colby
            wrote on last edited by
            #5

            I got:

            1
            86
            Message from:  "75.102.43.54"
            Message port:  12345
            Message:  "id=1&status=ok&config=mode=decoder,buffer=800,out_gain=+3,dn_relay1=1,ref_id=1078,ref_ip=75.102.43.54,audio_port=55000,time_stamp=1477364862"
            

            My environment:

            Linux paul-XPS-13-9343 4.8.0-26-generic #28-Ubuntu SMP Tue Oct 18 14:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
            QMake version 3.0
            Using Qt version 5.6.1 in /usr/lib/x86_64-linux-gnu
            

            Cheers.

            J 1 Reply Last reply
            4
            • Paul ColbyP Paul Colby

              I got:

              1
              86
              Message from:  "75.102.43.54"
              Message port:  12345
              Message:  "id=1&status=ok&config=mode=decoder,buffer=800,out_gain=+3,dn_relay1=1,ref_id=1078,ref_ip=75.102.43.54,audio_port=55000,time_stamp=1477364862"
              

              My environment:

              Linux paul-XPS-13-9343 4.8.0-26-generic #28-Ubuntu SMP Tue Oct 18 14:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
              QMake version 3.0
              Using Qt version 5.6.1 in /usr/lib/x86_64-linux-gnu
              

              Cheers.

              J Offline
              J Offline
              Jeffson
              wrote on last edited by
              #6

              @Paul-Colby my god,thanks very much,Paul.I have stuck here for 4 days.You saved me.

              1 Reply Last reply
              2

              • Login

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