// test for IPv6 related issues in Sun's JDK for Linux // before running the test you need to execute // sudo sysctl -w net.ipv6.bindv6only=1 // // and you need to specify a local IPv4 address as the first argument, // something like 192.168.1.101, but 127.0.0.1 won't work // Author: Torsten Werner // public domain import java.io.*; import java.net.*; class FullTest { public static void main(String [] args) throws IOException { InetAddress localAddress = null; InetAddress remoteAddress = null; try { localAddress = InetAddress.getByName(args[0]); remoteAddress = InetAddress.getByName("www.debian.org"); } catch (UnknownHostException e) { System.err.println( "Unable to resolve localhost name: " + e ); return; } int remotePort = 80; Socket testSocket = null; System.out.print("Test #1... "); try { testSocket = new Socket(remoteAddress, remotePort, localAddress, 0); System.out.println("passed."); } catch (IOException e) { System.out.println("failed."); } System.out.print("Test #2... "); try { testSocket = new Socket(remoteAddress, remotePort, null, 0); System.out.println("passed."); } catch (IOException e) { System.out.println("failed."); } } }