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
Servers for Qt installer are currently down

Can not send udp packet using writeDatagram

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.8k 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
    Jeffson
    wrote on 28 Oct 2016, 07:34 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.

    J 1 Reply Last reply 28 Oct 2016, 07:49
    0
    • J Jeffson
      28 Oct 2016, 07:34

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 28 Oct 2016, 07:49 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
      • P Offline
        P Offline
        Paul Colby
        wrote on 28 Oct 2016, 08:01 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 28 Oct 2016, 08:08
        2
        • P Paul Colby
          28 Oct 2016, 08:01

          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 28 Oct 2016, 08:08 last edited by
          #4

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

          P 1 Reply Last reply 28 Oct 2016, 08:10
          0
          • J Jeffson
            28 Oct 2016, 08:08

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

            P Offline
            P Offline
            Paul Colby
            wrote on 28 Oct 2016, 08:10 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 28 Oct 2016, 08:14
            4
            • P Paul Colby
              28 Oct 2016, 08:10

              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 28 Oct 2016, 08:14 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

              1/6

              28 Oct 2016, 07:34

              • Login

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