MLGetNetworkAddressList (C Function)

MLGetNetworkAddressList has been replaced by WSGetNetworkAddressList.

char ** MLGetNetworkAddressList(MLENV env,unsigned long *n)

returns a list of ASCII strings containing the IP addresses of all the configured network interfaces on a machine and the length of list in n.

Details

  • MLGetNetworkAddressList() loads the IP numbers for each active network interface on the machine.
  • MLGetNetworkAddressList() loads both IPv4 and IPv6 numbers.
  • MLGetNetworkAddressList() allocates memory to store the addresses that must be released. To release the memory allocated by MLGetNetworkAddressList(), call MLReleaseNetworkAddressList() on the list returned by MLGetNetworkAddressList().
  • MLGetNetworkAddressList() returns NULL on failure.
  • MLGetNetworkAddressList() is declared in the MathLink header file mathlink.h.

Examples

Basic Examples  (1)

#include "mathlink.h"

/* A function that reads the IP addresses available on a machine */

void f(MLENV env)
{
    char **theList = NULL;
    char *tmp;
    unsigned long length;

    theList = MLGetNetworkAddressList(env, &length);

    if(length > 0 && theList != (char **)0)
    {
        while((tmp = *theList++) != (char *)0)
        {
            /* ... */
        }

        MLReleaseNetworkAddressList(env, theList, length);
    }
}