QNetworkReply
-
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;
@ -
"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.
-
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;
@ -
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