DATA
- The type of the datagram block (array) to be operated with. Do
not provide an array type as the methods use to generic type for
defining an array argument.public interface BlockReceiver<DATA extends Serializable> extends Receivable
BlockReceiver
is used to receive datagram blocks (arrays) in a
unified way. The readDatagrams()
method provides the next available
datagram block from the counterpart BlockSender
or
DatagramSender
; in case there is none available, then this method
halts until one is available or the BlockReceiver
is being shut down
or the underlying connection is closed. The Receivable.hasDatagram()
method
returns true in case a next datagram(s) can be fetched via the
readDatagrams()
method from the BlockReceiver
counterpart.org.refcodes.component.ConnectableComponent.ConnectableAutomaton
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
org.refcodes.component.Closable.CloseAutomaton
Modifier and Type | Method and Description |
---|---|
DATA[] |
readDatagrams()
Reads (receives) the next datagram block passed from a
BlockSender or DatagramSender counterpart. |
hasDatagram
DATA[] readDatagrams() throws org.refcodes.component.OpenException, InterruptedException
BlockSender
or DatagramSender
counterpart. In case none
datagram block is available, then this method blocks until one is
available. To prevent blocking, use the Receivable.hasDatagram()
method to
test beforehand whether a datagram is available (in a multi threaded
usage scenario, #hasBlock()
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.BlockSender
or
DatagramReceiver
counterpart.org.refcodes.component.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.Copyright © 2017. All rights reserved.