You don't know how much data will be available when you read. E.g. if the last time the socket was written to was 16KB for example, you might read less than this or more than this.
You have to write code which assumes you don't need to know. This allows you to prcess data as it arrives regardless of length.
If you are expecting to send a fixed length block of data, send the size first.
byte[] bytes = new byte[1024];
final DataInputStream in = new DataInputStream(s.getInputStream());
int length = in.readInt();
if (length > bytes.length) bytes = new byte[length];
in.readFully(bytes, 0, length); // read length bytes or throw an exception.