コード例 #1
0
void TQIODeviceTransport::write(const uint8_t* buf, uint32_t len)
{
  while (len) {
    uint32_t written = write_partial(buf, len);
    len -= written;
    dev_->waitForBytesWritten(50);
  }
}
コード例 #2
0
ファイル: TSocket.cpp プロジェクト: LonelyPale/fbthrift
void TSocket::write(const uint8_t* buf, uint32_t len) {
  uint32_t sent = 0;

  while (sent < len) {
    uint32_t b = write_partial(buf + sent, len - sent);
    if (b == 0) {
      // This should only happen if the timeout set with SO_SNDTIMEO expired.
      // Raise an exception.
      // However, first set SO_LINGER to 0 seconds for this socket.  We think
      // the remote endpoint is not responding, so when we call close() we just
      // want the server to drop any untransmitted data immediately, instead of
      // moving into the TCP_FIN_WAIT1 state and continuing to try and send it.
      setLinger(true, 0);
      throw TTransportException(TTransportException::TIMED_OUT,
                                "send timeout expired " + getSocketInfo());
    }
    sent += b;
  }
}