Monday 21 April 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());
    }
}
}

1 comment:

  1. public void Ip(Bsil_AXELXlLabelPrintingHistory _AXELXlLabelPrintingHistory)
    {
    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();

    _AXELXlLabelPrintingHistory.IpAddress ="";
    while (enumerator.MoveNext())
    {
    address = enumerator.get_Current();
    addressFamily = address.get_AddressFamily();

    if (addressFamily == System.Net.Sockets.AddressFamily::InterNetwork)
    {

    _AXELXlLabelPrintingHistory.IpAddress=address.ToString();

    }
    }
    }

    the above code, gives only server ip address.
    i want client ip address.

    ReplyDelete