void send(int code, MessageLite req) throws IOException {
   int len = req.getSerializedSize();
   dout.writeInt(len + 1);
   dout.write(code);
   req.writeTo(dout);
   dout.flush();
 }
예제 #2
0
  public boolean tryWrite(MessageLite message) {
    try {
      codedOutput.writeRawLittleEndian32(message.getSerializedSize());
      message.writeTo(codedOutput);
      // writes to the underlying output stream
      codedOutput.flush();

      return connection.tryFlush();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }