hi
Using connectToHost() with QUdp socket works fine for writing data with write() function.The code below works fine.
int i=5;
socket.write((char*)&i,sizeof(int));
QUdpSocket socket;
socket.connectToHost(QHostAddress::LocalHost,9930);
int i=5;
socket.write((char*)&i,sizeof(int));
To copy to clipboard, switch view to plain text mode
But using connectToHost() for reading does not work.The below code doesnot work.
if(socket.waitForReadyRead(2000)) //never enters inside this if
qDebug()<<QString(socket.readAll());
QUdpSocket socket;
socket.connectToHost(QHostAddress::LocalHost,9930);
if(socket.waitForReadyRead(2000)) //never enters inside this if
qDebug()<<QString(socket.readAll());
To copy to clipboard, switch view to plain text mode
Bookmarks