public class NioBlockingSelector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
NioBlockingSelector.BlockPoller |
static class |
NioBlockingSelector.KeyReference |
Modifier and Type | Field and Description |
---|---|
protected NioBlockingSelector.BlockPoller |
poller |
protected java.nio.channels.Selector |
sharedSelector |
Constructor and Description |
---|
NioBlockingSelector() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
open(java.nio.channels.Selector selector) |
int |
read(java.nio.ByteBuffer buf,
NioChannel socket,
long readTimeout)
Performs a blocking read using the bytebuffer for data to be read
If the
selector parameter is null, then it will perform a busy read that could
take up a lot of CPU cycles. |
int |
write(java.nio.ByteBuffer buf,
NioChannel socket,
long writeTimeout)
Performs a blocking write using the bytebuffer for data to be written
If the
selector parameter is null, then it will perform a busy write that could
take up a lot of CPU cycles. |
protected java.nio.channels.Selector sharedSelector
protected NioBlockingSelector.BlockPoller poller
public void open(java.nio.channels.Selector selector)
public void close()
public int write(java.nio.ByteBuffer buf, NioChannel socket, long writeTimeout) throws java.io.IOException
selector
parameter is null, then it will perform a busy write that could
take up a lot of CPU cycles.buf
- ByteBuffer - the buffer containing the data, we will write as long as (buf.hasRemaining()==true)
socket
- SocketChannel - the socket to write data towriteTimeout
- long - the timeout for this write operation in milliseconds, -1 means no timeoutjava.io.EOFException
- if write returns -1java.net.SocketTimeoutException
- if the write times outjava.io.IOException
- if an IO Exception occurs in the underlying socket logicpublic int read(java.nio.ByteBuffer buf, NioChannel socket, long readTimeout) throws java.io.IOException
selector
parameter is null, then it will perform a busy read that could
take up a lot of CPU cycles.buf
- ByteBuffer - the buffer containing the data, we will read as until we have read at least one byte or we timed outsocket
- SocketChannel - the socket to write data toreadTimeout
- long - the timeout for this read operation in milliseconds, -1 means no timeoutjava.io.EOFException
- if read returns -1java.net.SocketTimeoutException
- if the read times outjava.io.IOException
- if an IO Exception occurs in the underlying socket logicCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.