• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <uv.h>
3 
main()4 int main() {
5     char buf[512];
6     uv_interface_address_t *info;
7     int count, i;
8 
9     uv_interface_addresses(&info, &count);
10     i = count;
11 
12     printf("Number of interfaces: %d\n", count);
13     while (i--) {
14         uv_interface_address_t interface = info[i];
15 
16         printf("Name: %s\n", interface.name);
17         printf("Internal? %s\n", interface.is_internal ? "Yes" : "No");
18 
19         if (interface.address.address4.sin_family == AF_INET) {
20             uv_ip4_name(&interface.address.address4, buf, sizeof(buf));
21             printf("IPv4 address: %s\n", buf);
22         }
23         else if (interface.address.address4.sin_family == AF_INET6) {
24             uv_ip6_name(&interface.address.address6, buf, sizeof(buf));
25             printf("IPv6 address: %s\n", buf);
26         }
27 
28         printf("\n");
29     }
30 
31     uv_free_interface_addresses(info, count);
32     return 0;
33 }
34