test/java/nio/channels/DatagramChannel/IsBound.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 32,43 **** import java.nio.channels.*; public class IsBound { public static void main(String argv[]) throws Exception { InetSocketAddress isa = new InetSocketAddress( ! InetAddress.getByName(TestUtil.HOST), 13); ByteBuffer bb = ByteBuffer.allocateDirect(256); bb.put("hello".getBytes()); bb.flip(); DatagramChannel dc = DatagramChannel.open(); --- 32,46 ---- import java.nio.channels.*; public class IsBound { public static void main(String argv[]) throws Exception { + try (TestClass.UdpDayTimeServer daytimeServer + = TestClass.UdpDayTimeServer.startNewServer(100)) { InetSocketAddress isa = new InetSocketAddress( ! daytimeServer.getAddress(), ! daytimeServer.getPort()); ByteBuffer bb = ByteBuffer.allocateDirect(256); bb.put("hello".getBytes()); bb.flip(); DatagramChannel dc = DatagramChannel.open();
*** 49,54 **** --- 52,58 ---- dc = DatagramChannel.open(); if(dc.socket().isBound()) throw new Exception("Test failed"); dc.close(); } + } }