- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.io.AbstractEndPoint
-
- org.eclipse.jetty.io.SelectableChannelEndPoint
-
- org.eclipse.jetty.io.DatagramChannelEndPoint
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,EndPoint,ManagedSelector.Selectable
public class DatagramChannelEndPoint extends SelectableChannelEndPoint
An
EndPointimplementation based onDatagramChannel.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.EndPoint
EndPoint.Wrapper
-
-
Field Summary
Fields Modifier and Type Field Description static java.net.SocketAddressEOF
-
Constructor Summary
Constructors Constructor Description DatagramChannelEndPoint(java.nio.channels.DatagramChannel channel, ManagedSelector selector, java.nio.channels.SelectionKey key, org.eclipse.jetty.util.thread.Scheduler scheduler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.channels.DatagramChannelgetChannel()java.net.SocketAddressreceive(java.nio.ByteBuffer buffer)Receives data into the given buffer from the returned address.booleansend(java.net.SocketAddress address, java.nio.ByteBuffer... buffers)Sends to the given address the data in the given buffers.voidwrite(org.eclipse.jetty.util.Callback callback, java.net.SocketAddress address, java.nio.ByteBuffer... buffers)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.-
Methods inherited from class org.eclipse.jetty.io.SelectableChannelEndPoint
doClose, getLocalSocketAddress, getTransport, isOpen, needsFillInterest, onClose, onIncompleteFlush, onSelected, replaceKey, toEndPointString, updateKey
-
Methods inherited from class org.eclipse.jetty.io.AbstractEndPoint
close, close, doShutdownInput, doShutdownOutput, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getLocalAddress, getRemoteAddress, getRemoteSocketAddress, getWriteFlusher, isFillInterested, isInputShutdown, isOutputShutdown, onClose, onIdleExpired, onOpen, reset, setConnection, shutdownInput, shutdownOutput, toConnectionString, toString, tryFillInterested, upgrade, write
-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getScheduler, notIdle, setIdleTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.io.EndPoint
fill, flush, getIdleTimeout, setIdleTimeout
-
-
-
-
Constructor Detail
-
DatagramChannelEndPoint
public DatagramChannelEndPoint(java.nio.channels.DatagramChannel channel, ManagedSelector selector, java.nio.channels.SelectionKey key, org.eclipse.jetty.util.thread.Scheduler scheduler)
-
-
Method Detail
-
getChannel
public java.nio.channels.DatagramChannel getChannel()
- Overrides:
getChannelin classSelectableChannelEndPoint
-
receive
public java.net.SocketAddress receive(java.nio.ByteBuffer buffer) throws java.io.IOExceptionReceives 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.IOExceptionSends 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 tobuffers- 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(org.eclipse.jetty.util.Callback callback, java.net.SocketAddress address, java.nio.ByteBuffer... buffers) throws java.nio.channels.WritePendingExceptionWrites 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 operationaddress- the peer address to send data tobuffers- 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...)
-
-