I'm trying to write 0x87 in a Java socket I've created.
tcpSocket = new Socket(server, port);
tcpWriteToServer = new PrintWriter(tcpSocket.getOutputStream(), true);
byte [] header = {0x8, 0x7};
tcpWriteToServer.print(header);
On the server side I get:
Incoming Bytes: 0x5b 0x42 0x40 0x34 0x32 0x65 0x62 0x35 0x62 0x38 0x38
I tried to break down the problem and just send one byte:
tcpWriteToServer.print(header[0]);
For this I end up getting:
Incoming Bytes: 0x38
I'm not sure how that "3" in "0x38" gets read. I read "0x37" when I try to send "0x7".
The server side is written in python and I have no issues sending the bytes and reading correctly in python.
Any idea what I might be missing?
PrintWriter. It does not do what you think it does. Also there is noprint(byte[])method.