Package org.apache.tomcat.util.net
Class NioBlockingSelector
- java.lang.Object
-
- org.apache.tomcat.util.net.NioBlockingSelector
-
public class NioBlockingSelector extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
NioBlockingSelector.BlockPoller
static class
NioBlockingSelector.KeyReference
-
Field Summary
Fields Modifier and Type Field Description protected NioBlockingSelector.BlockPoller
poller
protected java.nio.channels.Selector
sharedSelector
protected static StringManager
sm
-
Constructor Summary
Constructors Constructor Description NioBlockingSelector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
open(java.lang.String name, 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 theselector
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 byte buffer for data to be written If theselector
parameter is null, then it will perform a busy write that could take up a lot of CPU cycles.
-
-
-
Field Detail
-
sm
protected static final StringManager sm
-
sharedSelector
protected java.nio.channels.Selector sharedSelector
-
poller
protected NioBlockingSelector.BlockPoller poller
-
-
Method Detail
-
open
public void open(java.lang.String name, java.nio.channels.Selector selector)
-
close
public void close()
-
write
public int write(java.nio.ByteBuffer buf, NioChannel socket, long writeTimeout) throws java.io.IOException
Performs a blocking write using the byte buffer for data to be written If theselector
parameter is null, then it will perform a busy write that could take up a lot of CPU cycles.- Parameters:
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 timeout- Returns:
- the number of bytes written
- Throws:
java.io.EOFException
- if write returns -1java.net.SocketTimeoutException
- if the write times outjava.io.IOException
- if an IO Exception occurs in the underlying socket logic
-
read
public int read(java.nio.ByteBuffer buf, NioChannel socket, long readTimeout) throws java.io.IOException
Performs a blocking read using the bytebuffer for data to be read If theselector
parameter is null, then it will perform a busy read that could take up a lot of CPU cycles.- Parameters:
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 timeout- Returns:
- the number of bytes read
- Throws:
java.io.EOFException
- if read returns -1java.net.SocketTimeoutException
- if the read times outjava.io.IOException
- if an IO Exception occurs in the underlying socket logic
-
-