[Interest] Handling IP V4 and V6 as a QTcpServer?
Thiago Macieira
thiago.macieira at intel.com
Mon Jan 13 23:57:09 CET 2020
On Monday, 13 January 2020 10:49:38 PST Jason H wrote:
> I an starting to see QHostAddress::toString() return things like:
> "::ffff:192.168.34.3", which is a IPv6 mapping. However when I try to
> connect to this address it does not work. That server is a QTcpServer bound
> as: _server.listen(QHostAddress::Any, PORT);
How are you trying to connect to that address?
> When the QHostAddress resolves to a IPv4 address, everything works. When it
> resolves to IPv6, it does not. When implementing servers with QTcpServer,
> how do I provide a service that works with both protocols? At the
> application level, I don't [want to] care with protocol they use.
The one thing you have to do is not hardcode any addresses or use the
constants with "IPv4". QtNetwork will prefer IPv6 (as it should) and
QTcpServer will accept IPv4 connections as you've seen.
> Lastly, is this documented anywhere?
There isn't anything to document because it's not what you need to do. It's
just removing incorrect assumptions from your code.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel System Software Products
More information about the Interest
mailing list