Code example for ServerSocketChannel

Methods: acceptisOpen

0
        } 
    } 
 
    public void testAccept_ClosedChannel() throws Exception { 
        this.serverChannel.close();
        assertFalse(this.serverChannel.isOpen());
        try { 
            this.serverChannel.accept();
            fail("Should throw ClosedChannelException");
        } catch (ClosedChannelException e) {
            // OK. 
        } 
    } 
 
    public void testAccept_Block_NoConnect() throws IOException { 
        assertTrue(this.serverChannel.isBlocking());
        ServerSocket gotSocket = this.serverChannel.socket();
        gotSocket.bind(localAddr1);
        // blocking mode , will block and wait for ever... 
        // so must close the server channel with another thread. 
Connect your IDE to all the code out there  Get Codota for Java