[Qt-interest] QAbstractSocket::connectToHost() and IPv6

Thiago Macieira thiago at kde.org
Tue Feb 16 19:42:59 CET 2010


Em Terça-feira 16. Fevereiro 2010, às 16.54.44, Volker escreveu:
> QAbstractSocket::connectToHost( const QString & hostName, quint16 port,
> OpenMode openMode = ReadWrite )
> 
> is called with a hostName which resolves to both IPv4 and IPv6 addresses -
> which protocol will be used?

Depends on your operating system and its configuration.

Most systems (all?) sort IPv6 first, so IPv6 will be tried first.

> Can QAbstractSocket/QTcpSocket be restricted to IPv4?

Yes. Don't connect to a hostname, connect to an IP. Like:

Instead of:
	socket->connectToHost("qt.nokia.com", 80);
write:
	socket->connectToHost("87.238.50.178", 80)

If you don't know the IP, use QHostInfo and try to connect only to IPv4.

> Can IPv6 support be disabled at run time?

Not in Qt. You have to disable globally in the operating system.

I refuse to add any support for disabling IPv6. Remember that the current 
estimates are that IPv4 will run out before the end of next year.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100216/2bca7992/attachment.bin 


More information about the Qt-interest-old mailing list