org.apache.tomcat.util.net

## Class NioBlockingSelector

- java.lang.Object
- - org.apache.tomcat.util.net.NioBlockingSelector

-     public class NioBlockingSelector
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `NioBlockingSelector.BlockPoller`
    `static class` | `NioBlockingSelector.KeyReference`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected NioBlockingSelector.BlockPoller` | `poller`
    `protected Selector` | `sharedSelector`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NioBlockingSelector()`

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### sharedSelector

          protected Selector sharedSelector

    - #### poller

          protected NioBlockingSelector.BlockPoller poller

  - ### Constructor Detail

    - #### NioBlockingSelector

          public NioBlockingSelector()

  - ### Method Detail

    - #### open

          public void open(Selector selector)

    - #### close

          public void close()

    - #### write

          public int write(ByteBuffer buf,
                  NioChannel socket,
                  long writeTimeout)
                    throws IOException

      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.
      Parameters:
        `buf` - ByteBuffer - the buffer containing the data, we will write as long as `(buf.hasRemaining()==true)`
        `socket` - SocketChannel - the socket to write data to
        `writeTimeout` - long - the timeout for this write operation in milliseconds, -1 means no timeout
      Returns:
        int - returns the number of bytes written
      Throws:
        `EOFException` - if write returns -1
        `SocketTimeoutException` - if the write times out
        `IOException` - if an IO Exception occurs in the underlying socket logic

    - #### read

          public int read(ByteBuffer buf,
                 NioChannel socket,
                 long readTimeout)
                   throws IOException

      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.
      Parameters:
        `buf` - ByteBuffer - the buffer containing the data, we will read as until we have read at least one byte or we timed out
        `socket` - SocketChannel - the socket to write data to
        `readTimeout` - long - the timeout for this read operation in milliseconds, -1 means no timeout
      Returns:
        int - returns the number of bytes read
      Throws:
        `EOFException` - if read returns -1
        `SocketTimeoutException` - if the read times out
        `IOException` - if an IO Exception occurs in the underlying socket logic

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.