c-socket-programming:inet_pton
تفاوتها
تفاوت دو نسخهٔ متفاوت از صفحه را مشاهده میکنید.
| نگارش قبل در دو طرفنگارش قبلنگارش بعد | نگارش قبل | ||
| c-socket-programming:inet_pton [2024/06/18 01:52] – pejman | c-socket-programming:inet_pton [2024/06/18 22:49] (فعلی) – pejman | ||
|---|---|---|---|
| خط 10: | خط 10: | ||
| تعریف struct in_addr به شکل زیر است | تعریف struct in_addr به شکل زیر است | ||
| <code C> | <code C> | ||
| - | // man 7 ip | ||
| - | // man 3 inet | ||
| - | // Internet address (a structure for historical reasons) | ||
| typedef uint32_t in_addr_t; | typedef uint32_t in_addr_t; | ||
| struct in_addr { | struct in_addr { | ||
| خط 23: | خط 20: | ||
| <code C> | <code C> | ||
| // inet_pton-ipv4.c | // inet_pton-ipv4.c | ||
| + | // gcc -std=c99 -o inet_pton-ipv4 inet_pton-ipv4.c | ||
| #include < | #include < | ||
| #include < | #include < | ||
| خط 60: | خط 58: | ||
| <code C> | <code C> | ||
| + | // inet_pton-ipv4.c | ||
| + | // gcc -std=c99 -Wall -Wextra -Werror -pedantic -o inet_pton-ipv4 inet_pton-ipv4.c | ||
| #include < | #include < | ||
| #include < | #include < | ||
| خط 65: | خط 65: | ||
| int main() | int main() | ||
| { | { | ||
| - | char *ipv4 = " | + | |
| - | unsigned int ui; | + | unsigned int ui; |
| - | inet_pton(AF_INET, | + | |
| - | printf(" | + | |
| - | printf(" | + | printf(" |
| - | printf(" | + | printf(" |
| - | printf(" | + | printf(" |
| - | return 0; | + | |
| } | } | ||
| </ | </ | ||
| خط 93: | خط 93: | ||
| <code C> | <code C> | ||
| + | // inet_pton-ipv6.c | ||
| + | // gcc -std=c99 -Wall -Wextra -Werror -pedantic -o inet_pton-ipv6 inet_pton-ipv6.c | ||
| + | |||
| #include < | #include < | ||
| #include < | #include < | ||
| خط 98: | خط 101: | ||
| int main() | int main() | ||
| { | { | ||
| - | char *ipv6 = " | + | |
| - | struct in6_addr i6a; | + | struct in6_addr i6a; |
| - | inet_pton(AF_INET6, | + | |
| - | printf(" | + | |
| - | printf(" | + | printf(" |
| - | for(int i=0; i < sizeof(struct in6_addr); i++) | + | for(long unsigned |
| - | printf(" | + | |
| - | printf(" | + | printf(" |
| - | return 0; | + | |
| } | } | ||
| </ | </ | ||
c-socket-programming/inet_pton.1718662963.txt.gz · آخرین ویرایش: 2024/06/18 01:52 توسط pejman
