Hi, im trying to send/receive datagrams locally like this...
For the sender
udpSocket->connectToHost(leHost->text(), lePort->text().toUInt());
qDebug() << "sent :: " << udpSocket->write(datagram);
udpSocket->connectToHost(leHost->text(), lePort->text().toUInt());
QByteArray datagram = "//SearchingPlayers";
qDebug() << "sent :: " << udpSocket->write(datagram);
To copy to clipboard, switch view to plain text mode
Here i get 18 in console, then for the receiver...
while( udpSocket->hasPendingDatagrams() ){
datagram.resize(udpSocket->pendingDatagramSize());
datagram = udpSocket->read(datagram.size());
qDebug() << "received :: " << datagram.data();
}
QHostAddress *remoteHost = new QHostAddress;
while( udpSocket->hasPendingDatagrams() ){
QByteArray datagram;
datagram.resize(udpSocket->pendingDatagramSize());
datagram = udpSocket->read(datagram.size());
qDebug() << "received :: " << datagram.data();
}
To copy to clipboard, switch view to plain text mode
And it just freezes before qDebug(), each code is in different functions
Im using localhost in leHost and port the port i bind in udpSocket->bind(45454); before in the constructor
any ideas? thanks
Bookmarks