I have a problem for connection 2 computers. First (transmitter) run's on windows and second run's on linux (ubuntu 16.04). I'm transfer data through QUdpSocket between this 2 machines by local , but when transmit pass through, receiver catch nothing (I mean QT shows nothing). For check, is it work correct, i've used wireshark and it shows that it is connection between machines, all packets pass through. But QT show nothing! I've used simple qt example about receiving multicast packets. What am I do wrong?
On 2 windows machines all works correct.
my ip is 192.168.1.1 and netmask 255.255.255.0
I've add this code , see it below. I also add wireshark printscreen.
#include <QtWidgets>
#include <QtNetwork>
#include "receiver.h"
Receiver::Receiver(QWidget *parent)
: QDialog(parent)
{
groupAddress = QHostAddress("226.1.1.1");//QHostAddress("239.255.43.21");
statusLabel = new QLabel(tr("Listening for multicasted messages"));
quitButton = new QPushButton(tr("&Quit"));
udpSocket = new QUdpSocket(this);
udpSocket->bind(QHostAddress::AnyIPv4, 50100,QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint );//udpSocket->bind(QHostAddress::AnyIPv4, 45454, );
//udpSocket->setSocketOption(QAbstractSocket::MulticastTtlOption,QVariant(1));
//udpSocket->setMulticastInterface(QNetworkInterface::interfaceFromName(groupAddress.toString())); //getInterfaceByAddress()
udpSocket->joinMulticastGroup(groupAddress);
//bool flag = groupAddress.isMulticast();
connect(udpSocket, SIGNAL(readyRead()),
this, SLOT(processPendingDatagrams()));
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
buttonLayout->addWidget(quitButton);
buttonLayout->addStretch(1);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(statusLabel);
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
setWindowTitle(tr("Multicast Receiver"));
}
void Receiver::processPendingDatagrams()
{
while (udpSocket->hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(udpSocket->pendingDatagramSize());
udpSocket->readDatagram(datagram.data(), datagram.size());
statusLabel->setText(tr("Received datagram: \"%1\"").arg(datagram.data()));
}
}