Sending Unsigned Bytes Over Socket In Java -


i attempting send following byte array device running c.

bytes send: 80 3f 10 01 00 3c b2 5f 0d  bytes received machnine: 00 3f 10 01 00 3c 32 5f 0d 

it seems reason java turning signed bit 0 manipulating c machine reading.

80 -> 00 b2 -> 32 

here example of code:

try {     string response;     socket clientsocket = new socket(ipaddress, port);     dataoutputstream outtoserver = new dataoutputstream(clientsocket.getoutputstream());     bufferedreader infromserver = new bufferedreader(new inputstreamreader(clientsocket.getinputstream()));      byte[] bytes = new byte[] { (byte)0x80, 0x3f, 0x10, 0x01, 0x00, 0x3c, (byte) 0xb2, 0x5f, 0x0d};     outtoserver.write(bytes);      response = infromserver.readline();        system.out.println("from scu: " + response);     clientsocket.close(); } catch(exception e) {     e.printstacktrace(); } 

i absolutely lost can seems nothing work. not have access c machine in order change code.

for me looks "c machine" use 7 bits.

0x80 binrary represented 1000 0000, , 0xb2 binary 1011 0010. if 7 bits right 000 0000 = 0x00 , 011 0010 = 0x32

i hope may


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -