I'm currently writing a simple socket server on Windows 8 using VS 2013 and want it to listen on both 0.0.0.0 and [::] with the following socket initialization code:
int sock;
struct sockaddr_in6 addr;
memset(&addr, 0x0, sizeof(struct sockaddr_in6));
addr.sin6_family = AF_INET6;
addr.sin6_addr = in6addr_any;
addr.sin6_port = htons((uint16_t) myPort);
sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
if (sock == -1) {
fprintf(stderr, "\nsocket call failed\n");
WSACleanup();
return(1);
}
int off= 0;
setsockopt(sock, SOL_SOCKET, IPV6_V6ONLY, (void *)&off, sizeof(off));
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on));
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&on, sizeof(on));
ioctlsocket(sock, FIONBIO, &iMode);
rc = bind(sock, (const struct sockaddr*)&addr, sizeof(addr))
However, when I startup my application it appears to only be listening on [::] with the port I specify and not on 0.0.0.0.
EDIT: When I start a client application on the same host and tell it connect to my socket server application using the IP address of 127.0.0.1 I get a connection refused error. If I specify ::1, then I am able to connect to my server application.
Is there any additional configuration required to make a dual stack socket?