Package java.nio.channels

Examples of java.nio.channels.SelectionKey.cancel()


                if (writeTimeout > 0 && (selector == null || keycount == 0) ) timedout = (System.currentTimeMillis()-time)>=writeTimeout;
            }//while
            if ( timedout ) throw new SocketTimeoutException();
        } finally {
            if (key != null) {
                key.cancel();
                if (selector != null) selector.selectNow();//removes the key from this selector
            }
        }
        return written;
    }
View Full Code Here


                if (readTimeout > 0 && (selector == null || keycount == 0) ) timedout = (System.currentTimeMillis()-time)>=readTimeout;
            }//while
            if ( timedout ) throw new SocketTimeoutException();
        } finally {
            if (key != null) {
                key.cancel();
                if (selector != null) selector.selectNow();//removes the key from this selector
            }
        }
        return read;
    }
View Full Code Here

                                // Close socket and pool
                                try {
                                    KeyAttachment att = (KeyAttachment)socket.getAttachment(true);
                                    try {socket.close();}catch (Exception ignore){}
                                    if ( socket.isOpen() ) socket.close(true);
                                    key.cancel();
                                    key.attach(null);
                                    nioChannels.offer(socket);
                                    if ( att!=null ) keyCache.offer(att);
                                }catch ( Exception x ) {
                                    log.error("",x);
View Full Code Here

                                // Close socket and pool
                                try {
                                    KeyAttachment att = (KeyAttachment)socket.getAttachment(true);
                                    try {socket.close();}catch (Exception ignore){}
                                    if ( socket.isOpen() ) socket.close(true);
                                    key.cancel();
                                    key.attach(null);
                                    nioChannels.offer(socket);
                                    if ( att!=null ) keyCache.offer(att);
                                }catch ( Exception x ) {
                                    log.error("",x);
View Full Code Here

   
    public void close(MsgContext ep) throws IOException {
        Socket s=(Socket)ep.getNote( socketNote );
        SelectionKey key = s.getChannel().keyFor(selector);
        if(key != null) {
            key.cancel();
        }
        s.close();
    }

    public void destroy() throws IOException {
View Full Code Here

                                } else {
                                    SocketConnection sc = (SocketConnection)sk.attachment();
                                    sc.process(sk);
                                }
                            } else {
                                sk.cancel();
                            }
                            it.remove();
                        }
                    }
                } catch(ClosedSelectorException cse) {
View Full Code Here

   
    public void close(MsgContext ep) throws IOException {
        Socket s=(Socket)ep.getNote( socketNote );
        SelectionKey key = s.getChannel().keyFor(selector);
        if(key != null) {
            key.cancel();
        }
        s.close();
    }

    public void destroy() throws IOException {
View Full Code Here

                                } else {
                                    SocketConnection sc = (SocketConnection)sk.attachment();
                                    sc.process(sk);
                                }
                            } else {
                                sk.cancel();
                            }
                            it.remove();
                        }
                    }
                } catch(ClosedSelectorException cse) {
View Full Code Here

            SelectionKey selectionKey ;
            synchronized(deferredRegistrations) {
                selectionKey = eventHandler.getSelectionKey();
            }
            if (selectionKey != null) {
                selectionKey.cancel();
            }
            selector.wakeup();
            return;
        }
View Full Code Here

    private void dispatchDeregistered(ReactorHandler handler) {
        SelectableChannel[] channels = handler.getChannels();
        for (int i = 0; i < channels.length; i++) {
            SelectionKey key = channels[i].keyFor(selector);
            if (key != null)
                key.cancel();
        }
        handler.onDeregistered();
    }

    public void register(ReactorHandler handler) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.