I have this code to send an array of bytes through a socket:
byte[] code_b = code.getBytes("US-ASCII");
byte[] id_b = id.getBytes("US-ASCII");
byte[] username_b = username.getBytes("US-ASCII");
ByteBuffer chapAsk = ByteBuffer.allocate(lengthmsg);
chapAsk.put(code_b);
chapAsk.put(id_b);
chapAsk.putShort((short)(lengthmsg));
chapAsk.put(username_b);
chapAsk.array(); //several bytes together - concat
sal.println(chapAsk); //with this I send the array through the socket
With this I send the array but now I want to receive the array on the Socket Server and save the bytes in a new array. How can I do this??