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.