android - In Qt socket write data is not reaching the server -
android - In Qt socket write data is not reaching the server -
writing simple application communicate android device pc qt application.
on initial startup of app, succesfully able connect android app.
my signals:
connect(socket, signal(connected()),this, slot(connected())); connect(socket, signal(readyread()),this, slot(readyread())); void myapp::connected() { qdebug() << "connected..."; socket->write("init connection \n"); socket->flush(); } void myapp::readyread() { qstring readdata; qdebug() << "reading..."; while(socket->bytesavailable()) readdata= socket->readall(); qdebug()<<"read finished"; if(socket->iswritable()) { qdebug()<<"yes writable"; socket->write("new data"); socket->flush(); } else qdebug()<<"no writable"; }
in connected
method socket->write
successful , android app able read info in readyread
, socket->write
returning number of bytes written not reaching android app.
note: on application close or socket close, info read @ server end running in android app.
tell me if more info required.
edit:
1.android app running on tablet , qt pc app. both running on same network (intranet).
2.created qtcpscoket
in single program.
3.created serversocket
on android app , on socket>connecttohost(server_ip,portno,qiodevice::readwrite);
@ qt app onconnected
method called.subsequently socket->write("init connection \n");
read @ android app.
i can't leave comments, i'll write here. can utilize qiodevice
function bool qiodevice::waitforbyteswritten(int msecs) [virtual]
instead of bool flush()
. if pc application stops problem in writing info in sec time. or can check value returned function flush()
.
android c++ qt sockets
Comments
Post a Comment