Currently I am working on a Java client that sends binary data commands to a device panel. I am having a strange problem that if I am sending one command per socket connection (one TCP session) all commands work well. But when I send multiple commands in one connection (same TCP session), the first command is executed on the device panel perfectly but in the second command it gets two extra bytes with values 0x01 and 0x00. It's strange, and I have been trying for the last couple of days but could not find the answer.
My code:
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
sslsocket = (SSLSocket) sslsocketfactory.createSocket(deviceIP, port);
//Output Streams
OutputStream outputStream = sslsocket.getOutputStream();
outputStream.write(command1);
outputStream.write(command2);
Note that command1 and command2 are byte arrays:
- Value in command1 = 01,01,01
- Value in command2 = 01,34,45,34,56
Log of the device panel is:
Received command: 01 01 01
Received command: 01 00 01 03 45 34 56
What could be the problem? Your suggestions will be highly appreciated.