Class DatagramChannelEndPoint

All Implemented Interfaces:
Closeable, AutoCloseable, EndPoint, ManagedSelector.Selectable

public class DatagramChannelEndPoint extends SelectableChannelEndPoint

An EndPoint implementation based on DatagramChannel.

  • Field Details

  • Constructor Details

  • Method Details

    • getChannel

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

      public SocketAddress getRemoteSocketAddress()
      Specified by:
      getRemoteSocketAddress in interface EndPoint
      Specified by:
      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.
    • receive

      public SocketAddress receive(ByteBuffer buffer) throws IOException

      Receives data into the given buffer from the returned address.

      This method should be used to receive UDP data.

      Parameters:
      buffer - the buffer to fill with data
      Returns:
      the peer address that sent the data
      Throws:
      IOException - if the receive fails
    • send

      public boolean send(SocketAddress address, ByteBuffer... buffers) throws IOException

      Sends to the given address the data in the given buffers.

      This methods should be used to send UDP data.

      Parameters:
      address - the peer address to send data to
      buffers - the buffers containing the data to send
      Returns:
      true if all the buffers have been consumed
      Throws:
      IOException - if the send fails
      See Also:
    • write

      public void write(org.eclipse.jetty.util.Callback callback, SocketAddress address, ByteBuffer... buffers) throws WritePendingException

      Writes to the given address the data contained in the given buffers, and invokes the given callback when either all the data has been sent, or a failure occurs.

      Parameters:
      callback - the callback to notify of the success or failure of the write operation
      address - the peer address to send data to
      buffers - the buffers containing the data to send
      Throws:
      WritePendingException - if a previous write was initiated but was not yet completed
      See Also: