PDA

View Full Version : bad UDP socket :(



chaosgeorge
11th December 2006, 01:10
Hi, im trying to send/receive datagrams locally like this...
For the sender


udpSocket->connectToHost(leHost->text(), lePort->text().toUInt());
QByteArray datagram = "//SearchingPlayers";
qDebug() << "sent :: " << udpSocket->write(datagram);

Here i get 18 in console, then for the receiver...


QHostAddress *remoteHost = new QHostAddress;
while( udpSocket->hasPendingDatagrams() ){
QByteArray datagram;
datagram.resize(udpSocket->pendingDatagramSize());
datagram = udpSocket->read(datagram.size());
qDebug() << "received :: " << datagram.data();
}

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

chaosgeorge
11th December 2006, 03:55
well i got it, i have to bind both apps before sending anything :p