sending unsigned bytes to an outputStream socket
843790May 4 2010 — edited May 6 2010Hi
I'm trying to send unsigned bytes to an outputStream created via a socket call,
That is,
Socket skt = new Socket(ip, port);
OutputStream out = skt.getOutputStream();
To write to this stream I'm thinking of using the out.write(byte[]) method.
The problem is that I need to send unsigned bytes but Java only has singed bytes. There are no other methods that will work. I tried using out.write(int) after reading that
this method only sends the lower 8 bits of a 32 bit integer and discards the top 24 bits. This seemed like it should work but I need to send and array of 7 bytes and there is no method such as out.write(int[]). I tried just putting it in a loop but it froze my server connection. is there an obvious way to do this that I'm missing?
Thanks in advance for any help, Mike