Code example for ServerSocketChannel

Methods: isBlocking, isOpen, socket

0
 
    /* 
     * Test method for 'java.nio.channels.ServerSocketChannel.socket()' 
     */ 
    public void testSocket_Block_BeforeClose() throws Exception { 
        assertTrue(this.serverChannel.isOpen());
        assertTrue(this.serverChannel.isBlocking());
        ServerSocket s1 = this.serverChannel.socket();
        assertFalse(s1.isClosed());
        assertSocketNotAccepted(s1);
        ServerSocket s2 = this.serverChannel.socket();
        // same 
        assertSame(s1, s2);
 
        // socket close makes the channel close 
        s1.close();
        assertFalse(this.serverChannel.isOpen());
 
    } 
 
    public void testSocket_NonBlock_BeforeClose() throws Exception { 
        assertTrue(this.serverChannel.isOpen());