// First, write call id to buffer d
d.writeInt(call.id);
// Then write RPC data (the actual call) to buffer d
call.param.write(d);
ByteBuffer wrapper = d.wrapAsByteBuffer();
byte[] data = wrapper.array();
int dataLength = wrapper.limit();
out.writeInt(dataLength); // first put the data length
out.write(data, 0, dataLength);// write the data
out.flush();