0

I want a list of all the connected networks to my pc. consider my computer has 3 active internet connections i.e. Ethernet,WiFi and USB dongle .How can I list these connections in my application. I am using C language in my application. Secondly, can I use all these active connections simultaneously.

Paul Sen
  • 526
  • 1
  • 4
  • 20

1 Answers1

0

The following c program gives the network connections in your system.

#include<stdio.h>
#include<netdb.h>
int main()
{

        struct netent *networks;
        setnetent(1);
        while((networks = getnetent()) != NULL)
        {
                printf("%s\n",networks->n_name);
        }
        endnetent();

}

The getnetent function is used to get the network entry in the /etc/networks file. The structure netent is defined in the netdb.h header file. For more information read the man page for getnetent function. I hope this will help you.