Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why does QHostAddress::protocol() always return QAbstractSocket::IPv6Protocol

Why does QHostAddress::protocol() always return QAbstractSocket::IPv6Protocol

Scheduled Pinned Locked Moved Unsolved General and Desktop
networksocketipv6
7 Posts 4 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yvbbrjdr
    wrote on 4 Sept 2016, 08:46 last edited by
    #1

    When I establish IPv4 connection between a QTcpSocket and a QTcpServer, I find out that the socket.peerAddress().toString() returns a IPv6 version of IPv4 address, which is like ::ffff:192.168.1.100. And then I check the socket.peerAddress().protocol() and it returns QAbstractSocket::IPv6Protocol. Why does it return an IPv6 when I am using IPv4?

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yvbbrjdr
      wrote on 4 Sept 2016, 11:23 last edited by
      #2

      I found that it is the same in all platforms, including Windows, Linux, and macOS.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 4 Sept 2016, 20:29 last edited by
        #3

        Hi,

        AFAICS, your system is using a IPV4 mapped IPV6. So technically there's nothing wrong going on from a Qt point of view. The IPV4/IPV6 handling is done outside of Qt's scope and you get accurate information.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Y 1 Reply Last reply 5 Sept 2016, 16:04
        0
        • S SGaist
          4 Sept 2016, 20:29

          Hi,

          AFAICS, your system is using a IPV4 mapped IPV6. So technically there's nothing wrong going on from a Qt point of view. The IPV4/IPV6 handling is done outside of Qt's scope and you get accurate information.

          Y Offline
          Y Offline
          yvbbrjdr
          wrote on 5 Sept 2016, 16:04 last edited by
          #4

          @SGaist So I am trying to use the function QHostAddress::toIPv4Address(bool *ok) and check the "ok" to see if the IP address is a IPv4. Is that OK?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 5 Sept 2016, 20:34 last edited by
            #5

            AFAIK, it should be yes.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alex_la
              wrote on 14 Nov 2022, 22:33 last edited by
              #6

              It's a bug in Qt. Appears everytime. Even if disable IPv6 stack.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                ChrisW67
                wrote on 16 Nov 2022, 08:10 last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved