Package org.apache.tomcat.util.net
Class NioBlockingSelector
java.lang.Object
org.apache.tomcat.util.net.NioBlockingSelector
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NioBlockingSelector.BlockPollerprotected Selectorprotected static final StringManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidintread(ByteBuffer buf, NioChannel socket, long readTimeout) Performs a blocking read using the bytebuffer for data to be read If theselectorparameter is null, then it will perform a busy read that could take up a lot of CPU cycles.intwrite(ByteBuffer buf, NioChannel socket, long writeTimeout) Performs a blocking write using the byte buffer for data to be written If theselectorparameter is null, then it will perform a busy write that could take up a lot of CPU cycles.
-
Field Details
-
sm
-
poller
-
-
Constructor Details
-
NioBlockingSelector
public NioBlockingSelector()
-
-
Method Details
-
open
-
close
public void close() -
write
Performs a blocking write using the byte buffer for data to be written If theselectorparameter 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:
EOFException- if write returns -1SocketTimeoutException- if the write times outIOException- if an IO Exception occurs in the underlying socket logic
-
read
Performs a blocking read using the bytebuffer for data to be read If theselectorparameter 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:
EOFException- if read returns -1SocketTimeoutException- if the read times outIOException- if an IO Exception occurs in the underlying socket logic
-