From 9c3caca567b3efcbe58e9e687ecc99eef86323a0 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 6 Jan 2013 08:19:38 +0300 Subject: [PATCH] add ipv6 support --- config.h | 2 +- server.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.h b/config.h index 282594d..0d17686 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ #include "encrypt.h" // This is the IP address server will be used to accept new connection -#define SERVER_LISTEN "0.0.0.0" +#define SERVER_LISTEN "::0" // This is the port server will be used to accept new connection #define SERVER_PORT 8888 diff --git a/server.c b/server.c index 9848cf6..61d418b 100644 --- a/server.c +++ b/server.c @@ -568,13 +568,13 @@ int main(int argc, char *argv[]) uv_loop_t *loop = uv_default_loop(); uv_tcp_t listener; - struct sockaddr_in addr = uv_ip4_addr(server_listen, server_port); + struct sockaddr_in6 addr = uv_ip6_addr(server_listen, server_port); n = uv_tcp_init(loop, &listener); if (n) SHOW_UV_ERROR_AND_EXIT(loop); - n = uv_tcp_bind(&listener, addr); + n = uv_tcp_bind6(&listener, addr); if (n) SHOW_UV_ERROR_AND_EXIT(loop);