code: protected void read() throws Exception {
      InputStream is = socket.getInputStream();
      while (is.available() > 0) {
        byte[] bytes = new byte[1024 * 1024];
        int read = is.read(bytes);
        byte[] actuallyRead = new byte[read];
        System.arraycopy(bytes, 0, actuallyRead, 0, read);
        pushInput(actuallyRead);
      }
    }
docs: listen for a complete message.