AC_DEFINE([DEBUG], 1, [Define to enable debug output.])
fi])
+AC_ARG_ENABLE([ipv6],
+ [AC_HELP_STRING([--disable-ipv6],
+ [disable IPv6, for IPv4 only network stacks])],
+ [if test "x$enableval" = xno; then
+ AC_DEFINE([USE_IPV4_ONLY], 1, [Define to not use IPv6.])
+ fi])
+
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
AC_OUTPUT
int main(int argc, char **argv) {
int port;
int client_socket, server_socket;
+#ifdef USE_IPV4_ONLY
+ struct sockaddr_in server_in;
+#else
struct sockaddr_in6 server_in;
+#endif
size_t i;
pthread_t *threads;
threads[i] = thread;
}
+#ifdef USE_IPV4_ONLY
+ server_socket = socket(PF_INET, SOCK_STREAM, 0);
+#else
server_socket = socket(PF_INET6, SOCK_STREAM, 0);
+#endif
if (-1 == server_socket) {
perror("socket()");
return EXIT_FAILURE;
/* Bind to the listen socket. */
memset(&server_in, 0, sizeof(server_in));
+#ifdef USE_IPV4_ONLY
+ server_in.sin_family = AF_INET; /* IPv4 only */
+ server_in.sin_addr.s_addr = INADDR_ANY; /* bind to any address */
+ server_in.sin_port = htons((uint16_t)port); /* port to bind to */
+#else
server_in.sin6_family = AF_INET6; /* IPv6 (and IPv4) */
server_in.sin6_addr = in6addr_any; /* bind to any address */
server_in.sin6_port = htons((uint16_t)port); /* port to bind to */
+#endif
if (-1 == bind(server_socket, (struct sockaddr *)&server_in,
sizeof(server_in))) {
perror("bind()");