Update server.c

Fix multi addr bind: 
example ./ss-server -s 0 -s :: 
 2015-01-21 07:28:09 ERROR: bind: Address already in use
 2015-01-21 07:28:09 ERROR: Could not bind
 2015-01-21 07:28:09 ERROR: bind() error
This commit is contained in:
KrazyIvan-
2015-01-21 15:47:25 +08:00
parent 5e43ae1d42
commit 28b3793b23
+3
View File
@@ -167,6 +167,9 @@ int create_and_bind(const char *host, const char *port)
}
int opt = 1;
setsockopt(listen_sock, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt));
setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
#ifdef SO_NOSIGPIPE
setsockopt(listen_sock, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));