Module org.refcodes.io
Package org.refcodes.io
Interface DatagramsDestination<DATA extends Serializable>
-
- Type Parameters:
DATA
- the generic type
- All Superinterfaces:
DatagramDestination<DATA>
- All Known Subinterfaces:
BidirectionalConnectionTransceiver<DATA,INPUT,OUTPUT>
,BidirectionalStreamConnectionTransceiver<DATA>
,ConnectionDatagramsReceiver<DATA,CON>
,ConnectionDatagramsTransceiver<DATA,CON>
,DatagramsReceiver<DATA>
,DatagramsTransceiver<DATA>
,InputStreamConnectionReceiver<DATA>
- All Known Implementing Classes:
AbstractDatagramsReceiver
,AbstractInputStreamReceiver
,AbstractPrefetchInputStreamReceiver
,BidirectionalStreamConnectionTransceiverImpl
,BidirectionalStreamTransceiver
,DatagramsReceiverDecorator
,InputStreamConnectionReceiverImpl
,InputStreamReceiver
,LoopbackDatagramsReceiver
,LoopbackDatagramsTransceiver
,PrefetchBidirectionalStreamConnectionTransceiver
,PrefetchBidirectionalStreamTransceiver
,PrefetchInputStreamConnectionReceiver
,PrefetchInputStreamReceiver
- 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 DatagramsDestination<DATA extends Serializable> extends DatagramDestination<DATA>
TheDatagramsDestination
is used to receive data blocks (arrays) in a unified way. ThereceiveAll()
method provides the next available short block from the counterpartDatagramsTransmitter
orDatagramTransmitter
; in case there is none available, then this method halts until one is available.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DATA
receive()
Reads (receives) the next datagram passed from aDatagramTransmitter
counterpart.default DATA[]
receive(int aMaxSize)
Similar toreceiveAll()
though at maximum the amount of data as provided returned.default void
receive(DATA[] aBuffer, int aOffset, int aLength)
Receives a byte array with the number of datagrams specified inserted at the given offset.default DATA[]
receiveAll()
Reads (receives) the all currently available data.
-
-
-
Method Detail
-
receive
DATA receive() throws IOException, EOFException
Reads (receives) the next datagram passed from aDatagramTransmitter
counterpart. In case none datagram is available, then this method blocks until one is available. To prevent blocking, use theDatagramReceiver
extension'sAvailability.available()
method to test beforehand whether a byte is available (in a multi-threaded usage scenario,Availability.available()
is not a reliable indicator whether this method will block or not). When aThread
is waiting for a datagram to be read andThread.interrupt()
is being called, then the operation is aborted and anInterruptedException
is thrown.- Specified by:
receive
in interfaceDatagramDestination<DATA extends Serializable>
- Returns:
- The next datagram sent from the
DatagramTransmitter
counterpart. - Throws:
IOException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.EOFException
- Signals that an end of file or end of stream has been reached unexpectedly during input.
-
receiveAll
default DATA[] receiveAll() throws IOException, EOFException
Reads (receives) the all currently available data.- Returns:
- The next short block sent from the
DatagramsTransmitter
orDatagramReceiver
counterpart. - Throws:
IOException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.EOFException
- Signals that an end of file or end of stream has been reached unexpectedly during input.
-
receive
default DATA[] receive(int aMaxSize) throws IOException, EOFException
Similar toreceiveAll()
though at maximum the amount of data as provided returned.- Parameters:
aMaxSize
- the a block size- Returns:
- The next short block sent from the
DatagramsTransmitter
orDatagramReceiver
counterpart. - Throws:
IOException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.EOFException
- Signals that an end of file or end of stream has been reached unexpectedly during input.
-
receive
default void receive(DATA[] aBuffer, int aOffset, int aLength) throws IOException, EOFException
Receives a byte array with the number of datagrams specified inserted at the given offset. This method blocks till a datagrams is available.- Parameters:
aBuffer
- The datagrams array where to store the datagrams at.aOffset
- The offset where to start storing the received datagrams.aLength
- The number of datagrams to receive.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while receiving.EOFException
- Signals that an end of file or end of stream has been reached unexpectedly during input.
-
-