- int readLen = this.inFromSessiond.read(data, 0, data.length);
- if (readLen != data.length) {
- throw new IOException();
+ while (bytesLeft != 0) {
+ int bytesRead = this.inFromSessiond.read(data, bytesOffset, bytesLeft);
+
+ if (bytesRead < 0) {
+ throw new IOException();
+ }
+ bytesLeft -= bytesRead;
+ bytesOffset += bytesRead;