Hi Wysota,
Well, I have been programming those small Multicast handlers both under Linux and Windows. Actually Winsock is based also on the BSD "Like" socket lib ( Not MFC, just Winsock ), and they use the same system calls.
Well I tried using QUdpSocket but it doesn't catch any Multicasted packet. Here a simple example of code provided by Trolltech:
while (udpSocket->hasPendingDatagrams())
{
datagram.resize(udpSocket->pendingDatagramSize());
quint16 senderPort;
udpSocket->readDatagram(datagram.data(), datagram.size(),
&sender, &senderPort);
processTheDatagram(datagram);
}
QUdpSocket udpSocket = new QUdpSocket(this);
udpSocket->bind(QHostAddress::LocalHost, 24001);
while (udpSocket->hasPendingDatagrams())
{
QByteArray datagram;
datagram.resize(udpSocket->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
udpSocket->readDatagram(datagram.data(), datagram.size(),
&sender, &senderPort);
processTheDatagram(datagram);
}
To copy to clipboard, switch view to plain text mode
The problem here is pretty obvious : where do you join the multicast group ????
So I tried to put in the bind() function a QHostAddress containing the multicast address, but the bind function fails each time.
So, I don't know I do believe that Qt doesn't handle multicast by itself ?? Sad isn't it
Bookmarks