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



  • 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?



  • 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).



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.