From owner-freebsd-java@FreeBSD.ORG Fri Oct 17 07:10:23 2008 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 249E71065696 for ; Fri, 17 Oct 2008 07:10:23 +0000 (UTC) (envelope-from frank@harz.behrens.de) Received: from post.behrens.de (post.behrens.de [IPv6:2a01:170:1023::1:2]) by mx1.freebsd.org (Postfix) with ESMTP id 77B7C8FC1D for ; Fri, 17 Oct 2008 07:10:22 +0000 (UTC) (envelope-from frank@harz.behrens.de) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=behrens.de; h=from:to:date:mime-version:subject:in-reply-to:references:content-type:content-transfer-encoding:content-description; s=pinky1; t=1224227420; i=frank@harz.behrens.de; bh=WpVTskXISr5iLSEBDLxiYa/twAFeDURBUnoa9QUnPFE=; b=ZsYZNgUu1ColU8renNQkDVcoINIw0UTk9vHTHPXkGJijx2z7YXUIURmr0qftC1jEKBiHdFD/syZmX6PMTQuZ1w== Received: from sun.behrens ([IPv6:2a01:170:1023:0:b54e:dccd:b541:ac74]) by post.behrens.de (8.14.2/8.14.2) with ESMTP-MSA id m9H7AHkx080704 for ; Fri, 17 Oct 2008 09:10:17 +0200 (CEST) (envelope-from frank@harz.behrens.de) Message-Id: <200810170710.m9H7AHkx080704@post.behrens.de> From: "Frank Behrens" To: freebsd-java@freebsd.org Date: Fri, 17 Oct 2008 09:10:17 +0200 MIME-Version: 1.0 Priority: normal In-reply-to: <200810162241.54070.kurt@intricatesoftware.com> References: <200810141641.m9EGf4QG029110@post.behrens.de> X-mailer: Pegasus Mail for Windows (4.31, DE v4.31 R1) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Hashcash: 1:23:081017:freebsd-java@freebsd.org::WG0QK2UPXj2rmZwo:000000000NQ0H Subject: Re: Java and IPv6 on BSD - it does not work well X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2008 07:10:23 -0000 Kurt Miller wrote on 16 Oct 2008 22:41: > The networking support in the BSD port is based on the linux/solaris > code. When compiled with IPv6 support enabled the JDK uses only IPv6 > sockets and relies on IPv4 to IPv6 address mapping. For security > reasons all BSD's have v4mapped addresses turned off by default. If > you want both IPv6 and IPv4 support in the jdk on FreeBSD you must > 1) compile the JDK with IPv6 support, 2) change the > net.inet6.ip6.v6only sysctl to 0 using sysctl or via /etc/sysctl.conf, > and 3) Use only IPv6 addresses and special addresses as described in: I agree and 3) is the main problem. You can only use the special addresses. > What really needs to happen is to port the Windows approach in > the JVM to BSD. On Windows two sockets are created per ServerSocket; > one for IPV6 and another for IPv4. This avoids the need to use We should distinguish between two use caes: a) I want to use the "transparent and automatic" IPv6 support in Java. That means I create one server socket and want to be able to receive IPv4 and IPv6 packets. That works in Java for INADDR_ANY and IPV6_V6ONLY=0. For other addresses and/or IPV6_V6ONLY=1 you need two server sockets (Windows approach). BTW: It was not a surprise for me to see problems with a), it is a special case. b) I want to listen with a socket to a specific IPv6 address and with another socket to a specific IPv4 address. A special case? Not for other programming languages. In this case the Java runtime creates always an IPv6 socket and later tries to bind with an IPv4 or IPv6 address - of course it will fail for IPv4. Here the solution should be: At first determine the address type and create later the socket with right address family. I wonder, that I did not find error reports about this issue. Did nobody discover, that listening to "localhost" does not work on an IPv6 enabled system? -- Frank Behrens, Osterwieck, Germany PGP-key 0x5B7C47ED on public servers available.