tryipv6.c (610B)
1 /* ISC license. */ 2 3 #undef _POSIX_C_SOURCE 4 #undef _XOPEN_SOURCE 5 6 #define _XPG4_2 7 #define _XPG6 8 9 #include <errno.h> 10 #include <string.h> 11 #include <sys/socket.h> 12 #include <netinet/in.h> 13 14 int main (void) 15 { 16 int s, r ; 17 struct in6_addr foo ; 18 struct sockaddr_in6 bar ; 19 memset(&foo, 0, sizeof(struct sockaddr_in6)) ; 20 bar.sin6_addr = foo ; 21 bar.sin6_port = 1026 ; 22 s = socket(AF_INET6, SOCK_STREAM, 0) ; 23 if (s < 0) return 111 ; 24 do r = connect(s, (struct sockaddr *)&bar, sizeof bar) ; 25 while ((r == -1) && (errno == EINTR)) ; 26 if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; 27 return 0 ; 28 }