Alternatives for inet_addr() method and ntohl() method in winrt RRS feed

  • Question

  • Hi,

    I am portin of win32 code to winrt, I could not find an alternative for  inet_addr()  method and ntohl() method in winrt.
    Please suggest some alternatives for these methods.



    • Edited by AKEV Wednesday, November 21, 2012 11:46 AM
    Wednesday, November 21, 2012 11:45 AM


  • In winsock, ntohl()/htonl()  function just reverse the byte order. So you can implement it easily by changing byte order.


    In winsock, inet_addr function converts a string containing an IPv4 dotted-decimal address into an unsigned long value. In performing different socket operation this unsigned long value is used.

    As HostName class can take both dotted-decimal and domain name, it is unnecessary to have such a function like inet_addr.

    As you mention, you are porting legacy code so you need to implement it manually. You can do it by segregating four octets and then performing some bit-wise operation.

    • Marked as answer by AKEV Thursday, November 22, 2012 6:29 AM
    Wednesday, November 21, 2012 3:04 PM