# HG changeset patch # User fuchita # Date 1194603306 -32400 # Node ID 2d51078d94ddfb7652c20e40c672027edd375928 # Parent ad1060ba4213683b5cff9a33af51db76a0cacbb2 edit disconnet key.cancel and accept diff -r ad1060ba4213 -r 2d51078d94dd rep/REPPacketReceive.java --- a/rep/REPPacketReceive.java Fri Nov 09 17:52:54 2007 +0900 +++ b/rep/REPPacketReceive.java Fri Nov 09 19:15:06 2007 +0900 @@ -2,6 +2,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.LinkedList; import java.util.StringTokenizer; @@ -12,11 +13,16 @@ private final int HEADER_SIZE = 24; //private String host; //private int port; + SelectionKey key; public REPPacketReceive(SocketChannel sc){ socketchannel = sc; } - + + public void setkey(SelectionKey key) { + this.key = key; + //key.cancel(); + } public REPCommand unpack() { @@ -26,6 +32,9 @@ try { len = socketchannel.read(header); if(len == -1){ + if(key != null){ + key.cancel(); + } socketchannel.close(); return null; }else if(len == 0){