Why is the IPv4’s decimal value different with inet_pton and inet_addr (1734763876) than what you get if you use these 2 websites (1684366951) ?
struct sockaddr_in sin;
inet_pton(AF_INET, "100.101.102.103", &(sin.sin_addr));
printf("%i\n%i\n", inet_addr("100.101.102.103"), sin.sin_addr);
Endianness – they have the four bytes in opposite orders:
The value you’ll need to use for URLs etc. is the one in ‘Network’ order, Most-Significant-Byte first. Use
htonl()(host-to-network-long) to convert the value, i.e.caf points out below that I probably have this backwards: the issue is really that you need to convert the network-order data from the socket functions back into host-order for display, i.e.