Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Android network programming, how to read plastic data by socket,
Android network programming, how to read plastic data by socket,
mdataoutputclient . write int( 123); //send int

You can also use data types such as floating-point Boolean character bytes.

write float(val);

Write boolean value (val)

Write character (val)

data inputstream dis = new data inputstream(s . getinputstream());

int r = dis . readint(); //receive int

The data sent by socket is only binary. . . But at least one byte (char/byte) is sent at a time, that is, 8 bits of data are transmitted.

Receive hexadecimal. = = & gtbyte r = dis . read byte();

Send hexadecimal. = => byte r= (byte) 0xffdos. writebyte (r);