On 10/03/2017 04:52 PM, Thiago Macieira wrote:
If that doesn't fix the issue, can you make a simple example for what fails for
you? I need to test what's wrong.
I do bind to QHostAddress::AnyIPv4 and I get all the messages, but just
not destinationAddress/Port.
I've attached a minimal example and a small powershell script to send
the data.
Regards,
Richard
# send-udp
#
# Simple Tool to send UDP-Ports to a range with a various source port range.
# you can use Netmon/WireShark on the target to see the incomping traffic.
# i have NO listener to listen on all ports
#
#
# Links: http://pshscripts.blogspot.de/2008/12/send-udpdatagramps1.html
param (
[string]$remoteip = "239.193.0.11", # IP to send to
[int]$remoteudpport=10101, # port to send to
[int]$sourceudpport = 0, # SourcePort, maybe empty uses and
available port
[string]$buffer = "SendUDP Message by msxfaq"
)
$udpClient = new-Object system.Net.Sockets.Udpclient($sourceport)
$byteBuffer = [System.Text.Encoding]::ASCII.GetBytes($Buffer)
$sendbytes = $udpClient.Send($byteBuffer, $byteBuffer.length, $remoteip,
$remoteudpport)
if ($sendbytes -ne $byteBuffer.length) {
write-host "Mismatch bytes"
}
#include <QtNetwork>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QUdpSocket socket;
if (!socket.bind(QHostAddress::AnyIPv4, 10101))
{
qWarning() << socket.error() << socket.errorString();
}
if(!socket.joinMulticastGroup(QHostAddress("239.193.0.11")))
{
qWarning() << socket.error() << socket.errorString();
}
QObject::connect(&socket, &QUdpSocket::readyRead, [&]
{
while (socket.hasPendingDatagrams())
{
auto datagram = socket.receiveDatagram();
qInfo() << "Data: " << datagram.data()
<< "destinationAddress: " << datagram.destinationAddress()//.toString()
<< "destinationPort: " << datagram.destinationPort();
}
});
return app.exec();
}
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest