public class NioBlockingSelector extends 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 Selector |
sharedSelector |
Constructor and Description |
---|
NioBlockingSelector() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
open(Selector selector) |
int |
read(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(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 Selector sharedSelector
protected NioBlockingSelector.BlockPoller poller
public void open(Selector selector)
public void close()
public int write(ByteBuffer buf, NioChannel socket, long writeTimeout) throws 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 timeoutEOFException
- if write returns -1SocketTimeoutException
- if the write times outIOException
- if an IO Exception occurs in the underlying socket logicpublic int read(ByteBuffer buf, NioChannel socket, long readTimeout) throws 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 timeoutEOFException
- if read returns -1SocketTimeoutException
- if the read times outIOException
- if an IO Exception occurs in the underlying socket logicCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.