Interface BytesReceiver

    • Method Detail

      • getInputStream

        default InputStream getInputStream()
        Retrieves the input stream from the underlying implementation as is (no TimeoutInputStream wrapping the original InputStream).
        Specified by:
        getInputStream in interface org.refcodes.mixin.InputStreamAccessor
        Returns:
        The according underlying InputStream.
      • receiveAllBytes

        default byte[] receiveAllBytes()
                                throws IOException
        Reads (receives) the all currently available data.
        Specified by:
        receiveAllBytes in interface BytesDestination
        Returns:
        The according data.
        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.
      • receiveBytes

        default byte[] receiveBytes​(int aMaxLength)
                             throws IOException
        Similar to BytesDestination.receiveAllBytes() though at maximum the amount of data as of the provided length returned.
        Specified by:
        receiveBytes in interface BytesDestination
        Parameters:
        aMaxLength - The block-size which is not to exceeded by the returned data. A value of -1 specifies to retrieve all available datagrams (same behavior as method BytesDestination.receiveAllBytes().
        Returns:
        The according data.
        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.
      • receiveByteWithin

        default byte receiveByteWithin​(long aTimeoutInMs)
                                throws IOException
        Receives a byte. This method blocks till a byte is available or the timeout has been reached.
        Parameters:
        aTimeoutInMs - The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).
        Returns:
        A accordingly received byte.
        Throws:
        IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.
      • receiveBytesWithin

        default byte[] receiveBytesWithin​(long aTimeoutInMs,
                                          int aLength)
                                   throws IOException
        Receives a byte array with the number of bytes specified. This method blocks till all bytes are read or the timeout has been reached.
        Parameters:
        aTimeoutInMs - The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).
        aLength - The number of bytes to receive.
        Returns:
        A byte array containing the accordingly received bytes.
        Throws:
        IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.
      • receiveBytesWithin

        default void receiveBytesWithin​(long aTimeoutInMs,
                                        byte[] aBuffer,
                                        int aOffset,
                                        int aLength)
                                 throws IOException
        Receives a byte array with the number of bytes specified inserted at the given offset. This method blocks till all bytes are read or the timeout has been reached.
        Parameters:
        aTimeoutInMs - The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).
        aBuffer - The byte array where to store the bytes at.
        aOffset - The offset where to start storing the received bytes.
        aLength - The number of bytes to receive.
        Throws:
        IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.