Selector selector = null;
try { selector = getSelectorPool().get(); }catch ( IOException x ) {}
try {
- nRead = getSelectorPool().read(socket.getBufHandler().getReadBuffer(),socket.getIOChannel(),selector,rto);
+ nRead = getSelectorPool().read(socket.getBufHandler().getReadBuffer(),socket,selector,rto);
} catch ( EOFException eof ) {
nRead = -1;
} finally {
//ignore
}
try {
- written = getSelectorPool().write(bytebuffer, socket.getIOChannel(), selector, writeTimeout);
+ written = getSelectorPool().write(bytebuffer, socket, selector, writeTimeout);
//make sure we are flushed
do {
if (socket.flush(selector)) break;
* @throws SocketTimeoutException if the write times out
* @throws IOException if an IO Exception occurs in the underlying socket logic
*/
- public int write(ByteBuffer buf, SocketChannel socket, Selector selector, long writeTimeout) throws IOException {
+ public int write(ByteBuffer buf, NioChannel socket, Selector selector, long writeTimeout) throws IOException {
SelectionKey key = null;
int written = 0;
boolean timedout = false;
}
if ( selector != null ) {
//register OP_WRITE to the selector
- if (key==null) key = socket.register(selector, SelectionKey.OP_WRITE);
+ if (key==null) key = socket.getIOChannel().register(selector, SelectionKey.OP_WRITE);
else key.interestOps(SelectionKey.OP_WRITE);
keycount = selector.select(writeTimeout);
}
* @throws SocketTimeoutException if the read times out
* @throws IOException if an IO Exception occurs in the underlying socket logic
*/
- public int read(ByteBuffer buf, SocketChannel socket, Selector selector, long readTimeout) throws IOException {
+ public int read(ByteBuffer buf, NioChannel socket, Selector selector, long readTimeout) throws IOException {
SelectionKey key = null;
int read = 0;
boolean timedout = false;
}
if ( selector != null ) {
//register OP_WRITE to the selector
- if (key==null) key = socket.register(selector, SelectionKey.OP_READ);
+ if (key==null) key = socket.getIOChannel().register(selector, SelectionKey.OP_READ);
else key.interestOps(SelectionKey.OP_READ);
keycount = selector.select(readTimeout);
}
* @return boolean
*/
public boolean flush(Selector s, long timeout) throws IOException {
- pool.write(netOutBuffer,sc,s,timeout);
+ pool.write(netOutBuffer,this,s,timeout);
return !netOutBuffer.hasRemaining();
}