diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 18:55:44 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 18:55:44 +0000 |
commit | 3534b428629be185e096be99e3bd5fdfe32d5544 (patch) | |
tree | 210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/sysdeps/tryipv6.c | |
download | skalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz |
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/sysdeps/tryipv6.c')
-rw-r--r-- | src/sysdeps/tryipv6.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/sysdeps/tryipv6.c b/src/sysdeps/tryipv6.c new file mode 100644 index 0000000..0c7f306 --- /dev/null +++ b/src/sysdeps/tryipv6.c @@ -0,0 +1,35 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#define _XPG4_2 +#define _XPG6 + +#include <sys/types.h> + +#if defined(__FreeBSD__) +# include <sys/param.h> +#endif + +#include <errno.h> +#include <string.h> +#include <sys/socket.h> +#include <netinet/in.h> + +int main (void) +{ + int s ; + register int r ; + struct in6_addr foo ; + struct sockaddr_in6 bar ; + memset(&foo, 0, sizeof(struct sockaddr_in6)) ; + bar.sin6_addr = foo ; + bar.sin6_port = 1026 ; + s = socket(AF_INET6, SOCK_STREAM, 0) ; + if (s < 0) return 111 ; + do r = connect(s, (struct sockaddr *)&bar, sizeof bar) ; + while ((r == -1) && (errno == EINTR)) ; + if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; + return 0 ; +} |