update NIO code to be more compatible with Java

This commit is contained in:
Joel Dice
2008-03-25 11:18:17 -06:00
parent 9cb21a29a6
commit 3a208edbbc
11 changed files with 156 additions and 75 deletions

View File

@ -16,9 +16,8 @@ import java.nio.ByteBuffer;
public abstract class SelectableChannel implements Channel {
private SelectionKey key;
public abstract int read(ByteBuffer b) throws Exception;
public abstract int write(ByteBuffer b) throws Exception;
public abstract boolean isOpen();
public abstract SelectableChannel configureBlocking(boolean v)
throws IOException;
public SelectionKey register(Selector selector, int interestOps,
Object attachment)
@ -29,6 +28,10 @@ public abstract class SelectableChannel implements Channel {
return key;
}
public boolean isOpen() {
return key != null;
}
public void close() throws IOException {
if (key != null) {
key.selector().remove(key);