[Interest] QUdpSocket, QNetworkDatagram and QNetworkInterface

Jason H jhihn at gmx.com
Tue Oct 29 20:29:01 CET 2019


I don't think any of that is Qt.
You can bind to a specific interface, but if you use Any, then it's up to the kernel which uses the routing tables and the "metric".
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         my.meraki.net   0.0.0.0         UG    100    0        0 enp2s0
10.12.0.0       *               255.255.248.0   U     600    0        0 wlp3s0
link-local      *               255.255.0.0     U     1000   0        0 wlp3s0
192.168.128.0   *               255.255.255.0   U     100    0        0 enp2s0


"What puzzles me is that supposedly, a cable connection is faster than a wifi connection."
Not true, you can have a wired connection of 100Mbit but WiFi does over 800Mbit now.

As for the rest, I'm not sure. Been a while since I used UDP.

> Sent: Tuesday, October 29, 2019 at 2:12 PM
> From: "Nuno Santos" <nunosantos at imaginando.pt>
> To: "interestqt-project.org" <interest at qt-project.org>
> Subject: [Interest] QUdpSocket, QNetworkDatagram and QNetworkInterface
>
> Hi,
> 
> I’m trying to understand how does Qt decides which QNetworkInterface will be used when a writeDatagram is called.
> 
> I’m currently on a system that has both cable and wifi connections available, however, when doing a QUdpSocket writeDatagram the packets are being sent from the wifi adaptor, at least this is what I can infer from the IP address that comes on the packet when it arrives the other machine. What puzzles me is that supposedly, a cable connection is faster than a wifi connection.
> 
> While investigating the Qt documentation, it seems that I can use the writeDatagram function of QUdpSocket and specify on the QNetworkDatagram which interface I want to use by using the setInterfaceIndex function.
> 
> Is there anyway of knowing which network interface will be used by a QUdpSocket when transmitting data via writeDatagram? Or should I explicitly setInterfaceIndex on QNetworkDatagram and use the writeDatagram QNetworkDatagram variant function in order to have full control?
> 
> Thanks!
> 
> Best regards,
> 
> Nuno
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>


More information about the Interest mailing list