DATA
- The type of the datagram to be operated with.public interface Receiver<DATA extends Serializable>
extends org.refcodes.component.ConnectableComponent.ConnectableAutomaton, org.refcodes.mixin.mixins.Releaseable
Receiver
is used to receive datagrams in a unified way. The
readDatagram()
method provides the next available datagram from the
counterpart Sender
; in case there is none available, then this method
halts until one is available or the Receiver
is being shut down or
the underlying connection is closed. The hasDatagram()
method
returns true in case a next datagram can be fetched via the
readDatagram()
method from the Receiver
counterpart.org.refcodes.component.ConnectableComponent.ConnectableAutomaton
org.refcodes.component.mixins.OpenedAccessor.OpenedMutator, org.refcodes.component.mixins.OpenedAccessor.OpenedProperty
org.refcodes.component.mixins.Closable.CloseAutomaton
Modifier and Type | Method and Description |
---|---|
boolean |
hasDatagram()
Determines whether a datagram is available from a
Sender and can
be retrieved via the readDatagram() method. |
DATA |
readDatagram()
Reads (receives) the next datagram passed from a
Sender
counterpart. |
DATA readDatagram() throws org.refcodes.component.traps.OpenException, InterruptedException
Sender
counterpart. In case none datagram is available, then this method blocks
until one is available. To prevent blocking, use the
hasDatagram()
method to test beforehand whether a datagram is
available (in a multi threaded usage scenario, hasDatagram()
is
not a reliable indicator whether this method will block or not).
When a Thread
is waiting for a datagram to be read and
Thread.interrupt()
is being called, then the operation is aborted
and an InterruptedException
is thrown.Receiver
counterpart.org.refcodes.component.traps.OpenException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.InterruptedException
- Thrown when a Thread
is waiting,
sleeping, or otherwise occupied, and the Thread
is
interrupted, either before or during the activity.boolean hasDatagram() throws org.refcodes.component.traps.OpenException
Sender
and can
be retrieved via the readDatagram()
method.readDatagram()
method.org.refcodes.component.traps.OpenException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.Copyright © 2015. All rights reserved.