PDA

View Full Version : QUdpSocket Echo server



hubipet
27th September 2011, 11:16
Hi everybody,

I try to build an echo sever using the QUdpSocket class.
The transmission from client to server is ok but if I try to answer on the same socket
with the QHostAddress and port I have from the readDatagramm nothing happens.
Server side:
QHostAddress PeerAddress;
quint16 PeerPort;

udpSocket->readDatagram(datagram.data(), datagram.size(), &PeerAddress, &PeerPort);
udpSocket->writeDatagram(SendBuffer.data(), SendBuffer.size(), PeerAddress, PeerPort);

I have read in another thread that the QUdpSocket class uses BSD sockets.
Another thread said reply using the same socket is not supported by QUdpSocket.

There are many examples of echo severs based on BSD sockets.
So, why doesn't it work with QUdpSockets?:confused:

regards