Interview Questions

Monday, May 12, 2014

FetchIpAddress From ax through X++ ax 2009

static void FetchIpAddress (Args _args)
{
System.String                       hostName = System.Net.Dns::GetHostName();
System.Net.IPHostEntry              hostEntry = System.Net.Dns::GetHostEntry(hostName);
System.Net.IPAddress[]              addresses = hostEntry.get_AddressList();
System.Net.IPAddress                address;
System.Net.Sockets.AddressFamily    addressFamily;
System.Collections.IEnumerator      enumerator = addresses.GetEnumerator();

while (enumerator.MoveNext())
{
    address = enumerator.get_Current();
    addressFamily = address.get_AddressFamily();
    if (addressFamily == System.Net.Sockets.AddressFamily::InterNetwork)
    {
        info(address.ToString());
    }
}
}

No comments:

Post a Comment