| 413 | } |
| 414 | |
| 415 | Status Socket::Write(const uint8_t *buf, int32_t amt, int32_t *nwritten) { |
| 416 | if (amt <= 0) { |
| 417 | return Status::NetworkError( |
| 418 | StringPrintf("invalid send of %" PRId32 " bytes", |
| 419 | amt), Slice(), EINVAL); |
| 420 | } |
| 421 | DCHECK_GE(fd_, 0); |
| 422 | int res; |
| 423 | RETRY_ON_EINTR(res, ::send(fd_, buf, amt, MSG_NOSIGNAL)); |
| 424 | if (res < 0) { |
| 425 | int err = errno; |
| 426 | return Status::NetworkError("write error", ErrnoToString(err), err); |
| 427 | } |
| 428 | *nwritten = res; |
| 429 | return Status::OK(); |
| 430 | } |
| 431 | |
| 432 | Status Socket::Writev(const struct ::iovec *iov, int iov_len, |
| 433 | int64_t *nwritten) { |