[Interest] Handling IP V4 and V6 as a QTcpServer?

Thiago Macieira thiago.macieira at intel.com
Tue Jan 21 16:55:53 CET 2020


On Tuesday, 21 January 2020 06:23:53 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?
> 
> The client is told what address to connect to, which is a IPv4 address, as a
> QString passed to QTcpSocket::connectToHost, which comes from a config
> file, whose address is a static IPv4 address on the network.

Can you reduce this to a testcase? There's something weird somewhere else in 
your application and it's not obvious to me what it would be.

> You are absolutely correct. I don't want to care at all, but later down the
> line, there is a test to see if the address connected to is a particular
> address. I guess the proper way to do that is to use
> QHostAddress::toIPv6Address() at all times?

No, you should not call that. You should not care what address type it is.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Interest mailing list