Code example for ByteChannel

Methods: close

0
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        } 
        ch.close();
    } 
 
    /** 
     * In the case we are using the java select() method, this method is used to 
     * trash the buggy selector and create a new one, registering all the 
     * sockets on it. 
     */ 
    @Override 
    protected void registerNewSelector() throws IOException { 
        synchronized (selector) {
            Set<SelectionKey> keys = selector.keys();
 
            // Open a new selector 
            Selector newSelector = Selector.open();
Connect your IDE to all the code out there  Get Codota for Java