Share this page

# LrJposChannel.getBytes

Low-level receive function that receives the bytes over the connection. It returns the total number of bytes read into the buffer.

`public static int getBytes(byte[] bytes) throws IOException`

`public static int getBytes(byte[] bytes, int seconds) throws IOException`

## Parameters

Parameter | Description
--- | ---
bytes | Byte array that represents the buffer for the received bytes.
seconds | Seconds to wait for the response.

## Return values

This function returns an integer that represents the length of the array received.

It returns -1 if there is no more data (because the end of the stream has been reached).

## Example

Copy code

    public void getBytesISOtest() throws Throwable{

            GenericPackager packager = new GenericPackager(PACKAGERCONFIGFILE);
            LrJposChannel.initChannel(LrJposChannel.ChannelType.ASCIIChannel, "localhost", 8000, packager);

            LrJposChannel.connect();

            LrISOMsg m = new LrISOMsg();
            m.setMTI("0100");
            m.set(ISO87Fields.PAN_PRIMARY_ACCOUNT_NUMBER, "1234567890000000000");
            m.set(3, "523456");
            m.set(4, "123456789121");
            m.set(12, "20241605108110"); //Date and time - n-14, CCYYMMDDhhmmss
            m.set(47, "32432");

            LrJposChannel.send(m);

            byte[] rb = new byte[2048];
            int len = LrJposChannel.getBytes(rb, 5);
            if (len > 0) {
                System.out.println("received bytes! - len - : " + len);
            }
            else {
                System.out.println("No response receieved");
            }

            LrJposChannel.disconnect();
            LrJposChannel.closeChannel();
     }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: