* Class Constant
*/
protected static int BUFFSIZE = 128000; // how many bytes our incoming buffer can hold (original)
- //protected static int BUFFSIZE = 8388608; // 8388608 = 2^23 bytes of memory (8MB) - this is required by our IHome speaker driver
protected static int MSG_LEN_SIZE = 4; // send length in the size of integer (4 bytes)
/**
ByteBuffer bb = ByteBuffer.allocate(MSG_LEN_SIZE);
bb.putInt(len);
output.write(bb.array(), 0, MSG_LEN_SIZE);
- //System.out.println("Sender about to send: " + Arrays.toString(bb.array()));
output.flush();
// Write the byte array
output.write(vals, 0, len);
- //System.out.println("Sender sending: " + len);
output.flush();
- //System.out.println("Sender about to receive ACK!");
receiveAck();
- //System.out.println("Sender about to send ACK!\n\n");
sendAck();
}
return null;
}
- //System.out.println("Receiver about to receive: " + input.available());
// Read the maxlen first - read 4 bytes here
byte[] lenBytes = new byte[MSG_LEN_SIZE];
input.read(lenBytes, 0, MSG_LEN_SIZE);
- //System.out.println("Receiver lenBytes: " + Arrays.toString(lenBytes));
int maxlen = ByteBuffer.wrap(lenBytes).getInt();
- //System.out.println("Receiver received length: " + maxlen);
// Receive until maxlen
if (maxlen>BUFFSIZE) {
System.out.println("IoTSocketClient/Server: Sending more bytes then will fit in buffer! Number of bytes: " + maxlen);
}
// we now send an acknowledgement to the server to let them
// know we've got it
- //System.out.println("Receiver about to send ACK!");
sendAck();
- //System.out.println("Receiver about to receive ACK!\n\n");
receiveAck();
return val;