Package org.refcodes.io
Interface DatagramProvider<DATA extends java.io.Serializable>
-
- Type Parameters:
DATA- The type of the datagram to be operated with. In case you wish to use array types, you might better use theBlockReceivertype.
- All Known Subinterfaces:
BidirectionalConnectionTransceiver<DATA,INPUT,OUTPUT>,BidirectionalStreamConnectionTransceiver<DATA>,ConnectionReceiver<DATA,CON>,ConnectionTransceiver<DATA,CON>,DatagramReceiver<DATA>,DatagramTransceiver<DATA>,InputStreamConnectionReceiver<DATA>,LoopbackReceiver<DATA>,LoopbackTransceiver<DATA>,Provider<DATA>,Receiver<DATA>,Transceiver<DATA>
- All Known Implementing Classes:
AbstractInputStreamReceiver,AbstractPrefetchInputStreamReceiver,AbstractReceiver,BidirectionalStreamConnectionTransceiverImpl,BidirectionalStreamTransceiverImpl,InputStreamConnectionReceiverImpl,InputStreamReceiverImpl,LoopbackReceiverImpl,LoopbackTransceiverImpl,PrefetchBidirectionalStreamConnectionTransceiverImpl,PrefetchBidirectionalStreamTransceiverImpl,PrefetchInputStreamConnectionReceiverImpl,PrefetchInputStreamReceiverImpl,ReceiverDecorator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface DatagramProvider<DATA extends java.io.Serializable>TheDatagramProvideris used to receive datagrams in a unified way. ThereadDatagram()method provides the next available datagram from the counterpartDatagramConsumer; in case there is none available.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DATAreadDatagram()Reads (receives) the next datagram passed from aDatagramSendercounterpart.
-
-
-
Method Detail
-
readDatagram
DATA readDatagram() throws org.refcodes.component.OpenException, java.lang.InterruptedException
Reads (receives) the next datagram passed from aDatagramSendercounterpart. In case none datagram is available, then this method blocks until one is available. To prevent blocking, use theDatagramReceiverextension'sReceivable.hasDatagram()method to test beforehand whether a byte is available (in a multi-threaded usage scenario,Receivable.hasDatagram()is not a reliable indicator whether this method will block or not). When aThreadis waiting for a datagram to be read andThread.interrupt()is being called, then the operation is aborted and anInterruptedExceptionis thrown.- Returns:
- The next datagram sent from the
DatagramSendercounterpart. - Throws:
org.refcodes.component.OpenException- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.java.lang.InterruptedException- Thrown when aThreadis waiting, sleeping, or otherwise occupied, and theThreadis interrupted, either before or during the activity.
-
-