Class DatagramChannelEndPoint

    • Field Detail

      • EOF

        public static final java.net.SocketAddress EOF
    • Constructor Detail

      • DatagramChannelEndPoint

        public DatagramChannelEndPoint​(java.nio.channels.DatagramChannel channel,
                                       ManagedSelector selector,
                                       java.nio.channels.SelectionKey key,
                                       Scheduler scheduler)
    • Method Detail

      • receive

        public java.net.SocketAddress receive​(java.nio.ByteBuffer buffer)
                                       throws java.io.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:
        java.io.IOException - if the receive fails
      • send

        public boolean send​(java.net.SocketAddress address,
                            java.nio.ByteBuffer... buffers)
                     throws java.io.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:
        java.io.IOException - if the send fails
        See Also:
        write(Callback, SocketAddress, ByteBuffer...)
      • write

        public void write​(Callback callback,
                          java.net.SocketAddress address,
                          java.nio.ByteBuffer... buffers)
                   throws java.nio.channels.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:
        java.nio.channels.WritePendingException - if a previous write was initiated but was not yet completed
        See Also:
        send(SocketAddress, ByteBuffer...)