NioSender (Apache Tomcat 10.1.16 API Documentation)
Description: declaration: package: org.apache.catalina.tribes.transport.nio, class: NioSender

Package org.apache.catalina.tribes.transport.nio

# Class NioSender

java.lang.Object
org.apache.catalina.tribes.transport.AbstractSender
org.apache.catalina.tribes.transport.nio.NioSender

All Implemented Interfaces:
  `DataSender`

public class NioSender extends AbstractSender
This class is NOT thread safe and should never be used with more than one thread at a time This is a state machine, handled by the process method States are: - NOT_CONNECTED -> connect() -> CONNECTED - CONNECTED -> setMessage() -> READY TO WRITE - READY_TO_WRITE -> write() -> READY TO WRITE | READY TO READ - READY_TO_READ -> read() -> READY_TO_READ | TRANSFER_COMPLETE - TRANSFER_COMPLETE -> CONNECTED

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final XByteBuffer`
  `ackbuf`
  `protected boolean`
  `complete`
  `protected boolean`
  `connecting`
  `protected byte[]`
  `current`
  `protected DatagramChannel`
  `dataChannel`
  `protected ByteBuffer`
  `readbuf`
  `protected int`
  `remaining`
  `protected Selector`
  `selector`
  `protected static final StringManager`
  `sm`
  `protected SocketChannel`
  `socketChannel`
  `protected ByteBuffer`
  `writebuf`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NioSender()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `connect()`
  connect - blocking in this operation
  `void`
  `disconnect()`
  disconnect TODO Implement this org.apache.catalina.tribes.transport.IDataSender method
  `byte[]`
  `getMessage()`
  `Selector`
  `getSelector()`
  `boolean`
  `isComplete()`
  `boolean`
  `process(SelectionKey key, boolean waitForAck)`
  State machine to send data.
  `protected boolean`
  `read()`
  `void`
  `reset()`
  `void`
  `setComplete(boolean complete)`
  `void`
  `setMessage(byte[] data)`
  sendMessage
  `void`
  `setMessage(byte[] data, int offset, int length)`
  `void`
  `setSelector(Selector selector)`
  `protected boolean`
  `write()`

  ### Methods inherited from class org.apache.catalina.tribes.transport.AbstractSender

  `getAddress, getAttempt, getConnectTime, getDestination, getDirectBuffer, getKeepAliveCount, getKeepAliveTime, getMaxRetryAttempts, getOoBInline, getPort, getRequestCount, getRxBufSize, getSoKeepAlive, getSoLingerOn, getSoLingerTime, getSoReuseAddress, getSoTrafficClass, getTcpNoDelay, getThrowOnFailedAck, getTimeout, getTxBufSize, getUdpPort, getUdpRxBufSize, getUdpTxBufSize, isConnected, isUdpBased, keepalive, setAddress, setAttempt, setConnected, setConnectTime, setDestination, setDirectBuffer, setKeepAliveCount, setKeepAliveTime, setMaxRetryAttempts, setOoBInline, setPort, setRequestCount, setRxBufSize, setSoKeepAlive, setSoLingerOn, setSoLingerTime, setSoReuseAddress, setSoTrafficClass, setTcpNoDelay, setThrowOnFailedAck, setTimeout, setTxBufSize, setUdpBased, setUdpPort, setUdpRxBufSize, setUdpTxBufSize, transferProperties`

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

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

- ## Field Details

  - ### sm

    protected static final StringManager sm

  - ### selector

    protected Selector selector

  - ### socketChannel

    protected SocketChannel socketChannel

  - ### dataChannel

    protected DatagramChannel dataChannel

  - ### readbuf

    protected ByteBuffer readbuf

  - ### writebuf

    protected ByteBuffer writebuf

  - ### current

    protected volatile byte[] current

  - ### ackbuf

    protected final XByteBuffer ackbuf

  - ### remaining

    protected int remaining

  - ### complete

    protected boolean complete

  - ### connecting

    protected boolean connecting

- ## Constructor Details

  - ### NioSender

    public NioSender()

- ## Method Details

  - ### process

    public boolean process(SelectionKey key, boolean waitForAck) throws IOException
    State machine to send data.
    Parameters:
      `key` - The key to use
      `waitForAck` - Wait for an ack
    Returns:
      `true` if the processing was successful
    Throws:
      `IOException` - An IO error occurred

  - ### read

    protected boolean read() throws IOException
    Throws:
      `IOException`

  - ### write

    protected boolean write() throws IOException
    Throws:
      `IOException`

  - ### connect

    public void connect() throws IOException
    connect - blocking in this operation
    Specified by:
      `connect` in interface `DataSender`
    Specified by:
      `connect` in class `AbstractSender`
    Throws:
      `IOException` - TODO Implement this org.apache.catalina.tribes.transport.IDataSender method

  - ### disconnect

    public void disconnect()
    disconnect TODO Implement this org.apache.catalina.tribes.transport.IDataSender method
    Specified by:
      `disconnect` in interface `DataSender`
    Specified by:
      `disconnect` in class `AbstractSender`

  - ### reset

    public void reset()

  - ### setMessage

    public void setMessage(byte[] data) throws IOException
    sendMessage
    Parameters:
      `data` - ChannelMessage
    Throws:
      `IOException` - TODO Implement this org.apache.catalina.tribes.transport.IDataSender method

  - ### setMessage

    public void setMessage(byte[] data, int offset, int length) throws IOException
    Throws:
      `IOException`

  - ### getMessage

    public byte[] getMessage()

  - ### isComplete

    public boolean isComplete()

  - ### getSelector

    public Selector getSelector()

  - ### setSelector

    public void setSelector(Selector selector)

  - ### setComplete

    public void setComplete(boolean complete)