Code example for ServerSocketChannel

Methods: configureBlocking, socket

0
    /** 
     * @tests ServerSocket#socket().accept() 
     */ 
    public void test_socket_accept_Nonblocking_Bound() throws IOException { 
        // regression test for Harmony-748 
        serverChannel.configureBlocking(false);
        ServerSocket gotSocket = serverChannel.socket();
        gotSocket.bind(localAddr1);
        try { 
            gotSocket.accept();
            fail("Should throw an IllegalBlockingModeException");
        } catch (IllegalBlockingModeException e) {
            // expected 
        } 
        serverChannel.close();
        try { 
            gotSocket.accept();
            fail("Should throw a ClosedChannelException");
        } catch (ClosedChannelException e) {
            // expected 
        }