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. QNetworkReply
Forum Update on Monday, May 27th 2025

QNetworkReply

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

    I am trying to send message through IP modem
    The given code sends the message successfully but the modem receives it 3 times. Is there anything wrong the code?
    I think the loop is executing 3 times!
    When I used the URL directly in browser it gives the message ID as reply
    Here in code I am not getting anything.
    Pls see my code and suggest me to do modification

    @
    QUrl myURL("http://31.103.3.167:81/sendmsg?user=admin&passwd=admin&cat=1&to=9869XXXXXX&text=hello");
    QNetworkRequest myRequest(myURL);
    QNetworkAccessManager myManager(this);
    QNetworkReply *reply=myManager.get(myRequest);
    QEventLoop loop;
    connect(reply,SIGNAL(finished()),&loop,SLOT(quit()));
    QByteArray byteData = reply->readAll();
    QString stringData(byteData);
    delete reply;
    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      "This example how to send a HTTP request and how to handle the response":http://developer.qt.nokia.com/wiki/Download_Data_from_URL might be useful to solve your problem.

      http://anavi.org/

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

        i think you forgot loop.exec() before the readAll(). so You create the event loop, but it is not running so it immediately executes the readAll() which will mostly return an empty byte array

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mukundansree
          wrote on last edited by
          #4

          I tried with loop.exec() also
          buth the problem is ,in the modem i am getting the message 3 times for one execution of the code
          is the loop.exec() is executing thrice
          by copying the same URL in to the browser i am getting the reply as message ID
          like "ID=23"

          @
          QUrl myURL("http://31.103.3.167:81/sendmsg?user=admin&passwd=admin&cat=1&to=9869XXXXXX&text=hello");
          QNetworkRequest myRequest(myURL);
          QNetworkAccessManager myManager(this);
          QNetworkReply *reply=myManager.get(myRequest);
          QEventLoop loop;
          connect(reply,SIGNAL(finished()),&loop,SLOT(quit()));
          loop.exec();
          QByteArray byteData = reply->readAll();
          QString stringData(byteData); delete reply;
          @

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            The request is sent only once. Are you on a mobile platform? It may be that the underlying system tries to send the message through different means of transport (WiFi, mobile netowork...)

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mukundansree
              wrote on last edited by
              #6

              Thanks for reply
              It is not on WIFI,Mobile , I am developing in Desktop only
              i replaced the loop with minimum code ie
              @
              QUrl myURL("http://31.103.3.167:81/sendmsg?user=admin&passwd=admin&cat=1&to=9869XXXXXX&text=hello");
              QNetworkRequest myRequest(myURL);
              QNetworkAccessManager myManager(this)
              myManager.get(myRequest);
              exec();
              @
              then also it sends the message three times.
              can u tell me how can debug ...so that i should know, how many times it is sending to the IP Modem
              I also tried to debug the exec() but it gives "true " only one time.it means that it is executing only once. Is there any other method to send request to IPModem just give me some hint ,i will try

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                Something additional must be odd in your application.

                A short, yet complete, compilable test case would bring more light into this mysterious case. With the snippets you've given, there's nothing more to say than that it should work.

                http://www.catb.org/~esr/faqs/smart-questions.html

                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