Skip to content

Instantly share code, notes, and snippets.

💦
Working from home

xuesong xuesongbj

💦
Working from home
  • Tencent
  • beijing
Block or report user

Report or block xuesongbj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xuesongbj
xuesongbj / inet_ntop and inet_pton example
Created May 15, 2019
inet_ntop and inet_pton example
View inet_ntop and inet_pton example
// 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
@xuesongbj
xuesongbj / How to compare an IPv6 is greater or less than in C
Created May 15, 2019
How to compare an IPv6 is greater or less than in C?
View How to compare an IPv6 is greater or less than in C
#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";
You can’t perform that action at this time.