Add static anetV6Only() function.

This function sets the IPV6_V6ONLY option to 1 to use separate stack
IPv6 sockets.
This commit is contained in:
Geoff Garside 2011-09-19 23:31:41 +01:00 committed by antirez
parent 62a3b7e3d9
commit 72a3922617

View File

@ -362,6 +362,16 @@ static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len) {
return ANET_OK;
}
static int anetV6Only(char *err, int s) {
int yes = 1;
if (setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,&yes,sizeof(yes)) == -1) {
anetSetError(err, "setsockopt: %s", strerror(errno));
close(s);
return ANET_ERR;
}
return ANET_OK;
}
int anetTcpServer(char *err, int port, char *bindaddr)
{
int s, rv;