Answer the question
In order to leave comments, you need to log in
QUdpSocket does not accept packets on windows but works on linux why?
groupAddress = QHostAddress(/*"192.168.0.102"*/"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, 45455, QUdpSocket::ShareAddress);
udpSocket->joinMulticastGroup(groupAddress);
connect(udpSocket, SIGNAL(readyRead()),
this, SLOT(processPendingDatagrams()));
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
Answer the question
In order to leave comments, you need to log in
Firewall turned off. "multicast exceptions" try catch ? I tried checking like this
if(!udpSocket->bind(QHostAddress(QHostAddress::AnyIPv4), portMulti, QUdpSocket::ReuseAddressHint|QUdpSocket::ShareAddress)) {
qDebug() <<"Бида все пропало1";
}
if(!udpSocket->joinMulticastGroup(groupAddress)) {
qDebug() <<"Бида все пропало2";
}
socket = new DatagramSocket(/*45454*/);
socket.setBroadcast(true);
InetAddress groupAddr = InetAddress.getByName("239.255.43.21"); //на этом (выдуманный) работает только на linux
//InetAddress groupAddr = InetAddress.getByName("192.168.0.102"); //на этом адресе работает
byte[] outbuf = makeStartPacket();
sendPacket(socket, groupAddr, outbuf);
private byte[] makeStartPacket() {
byte[] outPack = ("Ляляля").getBytes();
return outPack;
}
private void sendPacket(DatagramSocket socket, InetAddress groupAddr, byte[] outbuf)
throws IOException {
DatagramPacket packet;
packet = new DatagramPacket(outbuf, outbuf.length, groupAddr,
/*9901*//*2425*//*multiPort*/45455);
//outbuf = createLegacyDiscoveryRequest(socket);
socket.send(packet);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question