--- old/test/java/nio/channels/DatagramChannel/Connect.java Sun Jul 15 11:47:59 2012 +++ new/test/java/nio/channels/DatagramChannel/Connect.java Sun Jul 15 11:47:56 2012 @@ -43,7 +43,7 @@ static void test() throws Exception { Reactor r = new Reactor(); - Actor a = new Actor(r.port()); + Actor a = new Actor(r.address(), r.port()); invoke(a, r); } @@ -68,9 +68,11 @@ public static class Actor implements Sprintable { final int port; + final InetAddress address; Exception e = null; - Actor(int port) { + Actor(InetAddress address, int port) { + this.address = address; this.port = port; } @@ -87,13 +89,11 @@ ByteBuffer bb = ByteBuffer.allocateDirect(256); bb.put("hello".getBytes()); bb.flip(); - InetAddress address = InetAddress.getLocalHost(); InetSocketAddress isa = new InetSocketAddress(address, port); dc.connect(isa); dc.write(bb); // Try to send to some other address - address = InetAddress.getLocalHost(); InetSocketAddress bogus = new InetSocketAddress(address, 3333); try { dc.send(bb, bogus); @@ -130,6 +130,10 @@ int port() { return dc.socket().getLocalPort(); } + + InetAddress address() { + return dc.socket().getLocalAddress(); + } public void throwException() throws Exception { if (e != null)