Class SocketChannelEndPoint

All Implemented Interfaces:
Closeable, AutoCloseable, EndPoint, ManagedSelector.Selectable
Direct Known Subclasses:
NetworkTrafficSocketChannelEndPoint, UnixSocketEndPoint

public class SocketChannelEndPoint extends SelectableChannelEndPoint

An EndPoint implementation based on SocketChannel.

  • Constructor Details

  • Method Details

    • getChannel

      public SocketChannel getChannel()
      Overrides:
      getChannel in class SelectableChannelEndPoint
    • getRemoteSocketAddress

      public SocketAddress getRemoteSocketAddress()
      Specified by:
      getRemoteSocketAddress in interface EndPoint
      Overrides:
      getRemoteSocketAddress in class AbstractEndPoint
      Returns:
      The remote SocketAddress to which this EndPoint is connected, or null if this EndPoint is not connected to a Socket address.
    • doShutdownOutput

      protected void doShutdownOutput()
      Overrides:
      doShutdownOutput in class AbstractEndPoint
    • fill

      public int fill(ByteBuffer buffer) throws IOException
      Description copied from interface: EndPoint
      Fill the passed buffer with data from this endpoint. The bytes are appended to any data already in the buffer by writing from the buffers limit up to it's capacity. The limit is updated to include the filled bytes.
      Parameters:
      buffer - The buffer to fill. The position and limit are modified during the fill. After the operation, the position is unchanged and the limit is increased to reflect the new data filled.
      Returns:
      an int value indicating the number of bytes filled or -1 if EOF is read or the input is shutdown.
      Throws:
      IOException - if the endpoint is closed.
    • flush

      public boolean flush(ByteBuffer... buffers) throws IOException
      Description copied from interface: EndPoint
      Flush data from the passed header/buffer to this endpoint. As many bytes as can be consumed are taken from the header/buffer position up until the buffer limit. The header/buffers position is updated to indicate how many bytes have been consumed.
      Parameters:
      buffers - the buffers to flush
      Returns:
      True IFF all the buffers have been consumed and the endpoint has flushed the data to its destination (ie is not buffering any data).
      Throws:
      IOException - If the endpoint is closed or output is shutdown.