Figure 3

//
// Source code for Connect.NLM
//

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <nwconn.h>
#include <nwmisc.h>
#include "connect.h"

int main(int argc, char **argv)
{
   int ccode;
   int MaxConns;
   int conn;
   int lines=0;

   argc = argc;
   argv = argv;

   MaxConns = GetMaximumNumberOfStations();

   // connection 0 refers to the server
   // so let's start from 1
   for (conn = 1; conn < MaxConns; conn++)
      {
      char objectName[48];
      WORD objectType;
      long objectID;
      char loginTime[7];
      char networkNumber[4];
      char nodeNumber[6];

      // Try to get the object name, type, ID, and login time
      // along with the internet address
      if ( !GetConnectionInformation(conn,objectName,&objectType,&objectID,loginTime) &&
           !GetInternetAddress(conn,networkNumber,nodeNumber) )
         {
         // if objectName is not NULL, print it,
         // otherwise show NOT-LOGGED-IN like monitor.nlm
         if (*objectName)
            printf("%d:%s(%04X) - %08X\n",
               conn,
               objectName,
               IntSwap(objectType),
               objectID);
         else
            printf("%d:%s\n",
               conn,
               "NOT-LOGGED-IN");

         // Print out the address in human-readable form
         printf("Network Address: %02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x\n",
               networkNumber[0],
               networkNumber[1],
               networkNumber[2],
               networkNumber[3],
               nodeNumber[0],
               nodeNumber[1],
               nodeNumber[2],
               nodeNumber[3],
               nodeNumber[4],
               nodeNumber[5]
               );
         printf("\n");
         lines += 3;
         if (lines > 22)
            {
            lines = 0;
            PressAnyKeyToContinue();
            }
         }
      }

   return 0;
}

