Among new features of Qt 5.6 new method was added for QHostAddress:
QHostAddress::isMulticastThis bool method returns true if IPv4 or IPv6 address is multicast.
From wikipedia a multicast address is a logical identifier for a group of hosts in a network available to process datagrams or frames intended to be multicast for a network service.
Here is the test program which shows the output for different IPv4 addresses:
#include <QCoreApplication> #include <QDebug> #include <QHostAddress> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QHostAddress ipv4false("127.0.0.1"); qDebug() << ipv4false.isMulticast(); // false // The All Hosts multicast group addresses all // hosts on the same network segment. QHostAddress ipv4true("224.0.0.1"); qDebug() << ipv4true.isMulticast(); // true return a.exec(); }
It works the same way for IPv6 addresses.
No comments:
Post a Comment