My Socket client is written in C and sends the values in the format below:
x00\x2C\x02\x00\xE0\x00
Now I would like to read the hex values from the TCP/IP socket server which is written in Java.
What should be a approach to read the stream values in Java Socket?
I'm trying to read in the following way, but it does not work:
InputStream ins = sock.getInputStream();
int byteRead;
while((byteRead = ins.read()) != -1) {
System.out.println(Integer.toHexString(byteRead & 0xFF));
}
Socketin (and out) streams. The data as it is transmitted over the networks is always binary, so it only depends how you interpret it on receiving end.0x002C0200E000.You can read that withDataInputStream.readShort()/.readInt().