From owner-freebsd-java@FreeBSD.ORG Tue May 28 13:30:45 2013 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8EE835BE for ; Tue, 28 May 2013 13:30:45 +0000 (UTC) (envelope-from ronald-freebsd8@klop.yi.org) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.78]) by mx1.freebsd.org (Postfix) with ESMTP id 2993CAD7 for ; Tue, 28 May 2013 13:30:44 +0000 (UTC) Received: from smtp.greenhost.nl ([213.108.104.138]) by smarthost1.greenhost.nl with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1UhJz8-000719-IP for freebsd-java@freebsd.org; Tue, 28 May 2013 15:30:43 +0200 Received: from [81.21.138.17] (helo=ronaldradial.versatec.local) by smtp.greenhost.nl with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1UhJz5-00042E-6I for freebsd-java@freebsd.org; Tue, 28 May 2013 15:30:39 +0200 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes To: freebsd-java@freebsd.org Subject: Re: java && IPv6 References: <20130528120123.GA1687@tiny.Sisis.de> Date: Tue, 28 May 2013 15:30:35 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Ronald Klop" Message-ID: In-Reply-To: <20130528120123.GA1687@tiny.Sisis.de> User-Agent: Opera Mail/12.15 (Win32) X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: 0.8 X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.1 X-Scan-Signature: 3b058867a8808b2a73617ccb478d635a X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 May 2013 13:30:45 -0000 On Tue, 28 May 2013 14:01:24 +0200, Matthias Apitz wrote: > > Hello, > > I'm a C-programmer and want to do something in Java now; > > I want to write an IPv6 server in java which should do what my C written > IPv6-server does: > > - create the two sockets for IPv4 and IPv6 > - bind, listen > - monitor the sockets with "poll" and accept the connection on the > socket which is ready to be accepted; > > see the C-source at http://www.unixarea.de/ipv6-server.c.txt > it can be compiled and run and creates LISTEN on the two sockets, see > netstat output: > > ~/c]$ gcc ipv6-server.c > ~/c]$ ./a.out > family: 28 (PF_INET6) sin6_addr: [::] > LISTEN: IPv6 ... > family: 2 (PF_INET) sin_addr: [0.0.0.0] > LISTEN: IPv4 ... > > ~/c]$ netstat -an | fgrep 39999 > tcp4 0 0 *.39999 *.* LISTEN > tcp6 0 0 *.39999 *.* LISTEN > > when I do something similar on the same FreeBSD host in Java, I can't > manage to create the IPv6 LISTEN on the IP addr "::"; IPv4 works fine, > when I use as addr 'null'; > the source is here: http://www.unixarea.de/ipv6.java.txt > > ~/java]$ javac ipv6.java > ~/java]$ java -version > java version "1.6.0_03-p4" > Java(TM) SE Runtime Environment (build > 1.6.0_03-p4-guru_22_apr_2011_14_10-b00) > Java HotSpot(TM) Client VM (build > 1.6.0_03-p4-guru_22_apr_2011_14_10-b00, mixed mode) > ~/java]$ java -Djava.net.preferIPv6Stack=true ipv6 > java.net.SocketException: Protocol family unavailable > at java.net.PlainSocketImpl.socketBind(Native Method) > at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) > at java.net.ServerSocket.bind(ServerSocket.java:319) > at java.net.ServerSocket.(ServerSocket.java:185) > at ipv6$1.run(ipv6.java:18) > at java.lang.Thread.run(Thread.java:619) > > Any Java guru out here? Any comments on my Java class? Thanks > > matthias > Your Java is really really really old. ;-) I guess it was this one: http://www.freshports.org/java/jdk16/ It is even removed from the ports tree already. It is advised to use the more recent openjdk6 or openjdk7 ports. Ronald.