This file contains hidden or 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
// IPv6 demo of inet_ntop() and inet_pton() | |
// (basically the same except with a bunch of 6s thrown around) | |
struct sockaddr_in6 sa; | |
char str[INET6_ADDRSTRLEN]; | |
// store this IP address in sa: | |
inet_pton(AF_INET6, "2001:db8:8714:3a90::12", &(sa.sin6_addr)); | |
// now get it back and print it |
This file contains hidden or 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
#include <arpa/inet.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
const char *ip6str = "2a03:6300:1:103:211:5bff:fe31:13e1"; | |
const char *first = "2a03:6300:1:103:218:5bff:fe31:13e1"; | |
const char *last = "2a03:6300:1:103:220:5bff:fe31:13e1"; |