Added the setsockopt for IPV6_V6ONLY, in order to have IPv6 and IPv4 in two
authorviric@llimona
Fri, 16 Jun 2006 18:25:03 +0200
changeset 61 4cd174a9b698
parent 60 07f049b2c1b6
child 62 39bf7ecd7b21
Added the setsockopt for IPV6_V6ONLY, in order to have IPv6 and IPv4 in two
different sockets for the same port.
tcp_server.c
--- a/tcp_server.c	Tue May 30 13:07:54 2006 +0200
+++ b/tcp_server.c	Fri Jun 16 18:25:03 2006 +0200
@@ -158,7 +158,16 @@
 	if (setsockopt(socket_ipv6, SOL_SOCKET, SO_REUSEADDR,
 	                         (char *)&on,sizeof(on)) < 0)
 	{
-		fprintf(stderr, "IPv6 setsockopt() failed: %s.\n",
+		fprintf(stderr, "IPv6 setsockopt() failed for SO_REUSEADDR: %s.\n",
+			strerror(errno));
+		abort();
+	}
+
+	/* Es necessita per a que linux no fagi Bind del port IPv4 alhora */
+	if (setsockopt(socket_ipv6, IPPROTO_IPV6, IPV6_V6ONLY,
+	                         (char *)&on,sizeof(on)) < 0)
+	{
+		fprintf(stderr, "IPv6 setsockopt() failed for IPV6_V6ONLY: %s.\n",
 			strerror(errno));
 		abort();
 	}