Sorry to ask about what should be a simple thing, but I've been trying to use IPAddress.NetworkToHostOrder and IPAddress.HostToNetworkOrder to no avail. I'm on Windows rig, little endian. Here's tiny code for what's puzzling me:
using System;
using System.Net;
public class Program
{
public static void Main()
{
int addr = 1;
Console.WriteLine($"{IPAddress.NetworkToHostOrder(addr)}");
Console.WriteLine($"{IPAddress.HostToNetworkOrder(addr)}");
}
}
The output for this is:
16777216
16777216
The output for one of these should be 1, right? I've given up, and wrote a replacement to handle the byte sequencing issue, but it's driving me nuts that I haven't been able to use IPaddress for this.
int addr=1represents the same ip address either way is not correct.NetworkToHostOrdersimply callsHostToNetworkOrder. On BigEndian compilations it always returns the value passed in, otherwise it does some computation. github.com/microsoft/referencesource/blob/…