This repository has been archived by the owner on Nov 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdio.h> | ||
#include <uv.h> | ||
|
||
int main() { | ||
char buf[512]; | ||
uv_interface_address_t *info; | ||
int count, i; | ||
|
||
uv_interface_addresses(&info, &count); | ||
i = count; | ||
|
||
printf("Number of interfaces: %d\n", count); | ||
while (i--) { | ||
uv_interface_address_t interface = info[i]; | ||
|
||
printf("Name: %s\n", interface.name); | ||
printf("Internal? %s\n", interface.is_internal ? "Yes" : "No"); | ||
|
||
if (interface.address.address4.sin_family == AF_INET) { | ||
uv_ip4_name(&interface.address.address4, buf, sizeof(buf)); | ||
printf("IPv4 address: %s\n", buf); | ||
} | ||
else if (interface.address.address4.sin_family == AF_INET6) { | ||
uv_ip6_name(&interface.address.address6, buf, sizeof(buf)); | ||
printf("IPv6 address: %s\n", buf); | ||
} | ||
|
||
printf("\n"); | ||
} | ||
|
||
uv_free_interface_addresses(info, count); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters