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 QHostAddress().toIPv4Address() is different from inet_addr()?

Why QHostAddress().toIPv4Address() is different from inet_addr()?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 4.5k 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.
  • E Offline
    E Offline
    eyeofhell
    wrote on last edited by
    #1

    Hello.

    On Windows, QHostAddress().toIPv4Address() returns IP representation that is a reverted representation inet_addr() returns. For example:

    @QHostAddress( "192.168.0.1" ).toIPv4Address() != inet_add( "192.168.0.1" )@

    Why is such difference? And what is a good way to get "native" IP address representation that i can pass to third-party libraries or API functions?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Probably so as to get the same result an big and little-endian machines. The MS inet_add() function looks to be different for different endianesses (from the docs).

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • R Offline
        R Offline
        romankr
        wrote on last edited by
        #3

        read docks :)
        winsock takes in account different byte order of different network interfaces.

        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