I figured it out. Well, first I must be on the same port or I won't get the messages (duh). Next, I must use the same Localhost address. The following code works for sending and receiving messages from a single application:
sending thread:
udpSocket = new QUdpSocket(this);
udpSocket->writeDatagram(datagram.data(), datagram.size(),
QHostAddress::LocalHost, 45454);
receiving thread:
rcvSocket = new QUdpSocket(this);
rcvSocket->bind(QHostAddress::LocalHost,45454);
datagram.resize(rcvSocket->pendingDatagramSize());
rcvSocket->readDatagram(datagram.data(), datagram.size());
received_data = datagram.data(); //received_data is just a QString to store the datagram
Bookmarks