Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Inconsistent QHostAddress behavior



  • I have a QTcpSocket client that connects with a Remote (on Internet) tcp server. When I call socket.localAddress().toString() immediately after WaitforConnected call. It returns local/lan IP in format ::ffff:192.168.1.54 (IPv4 mapped IPv6). However, if I call it later after some data transfer then same call returns 192.168.1.54 (standard IPv4 format). After first call, QHostAddress.protocol() returns IPv6Protocol and after second call QHostAddress.protocol() returns IPv4Protocol.

    Remote server and local server are both using IPv4 addresses and my ISP doesn't support IPv6, so why is the first response in IPv6 format? How to get correct format?


Log in to reply