All pastes #333452 Raw Edit

Anonymous

public text v1 · immutable
#333452 ·published 2007-01-30 22:41 UTC
rendered paste body
int sock_read(int sockfd, char *buf, const size_t  count) {

  size_t bytes_read = 0;
  int    this_read;

  while (bytes_read < count) {
    do {
      this_read = read(sockfd, buf, count-bytes_read);
    } while (this_read < 0   &&   errno == EINTR);

    if (this_read < 0) {
      return this_read;
    } else if (this_read == 0) {
      return bytes_read;
    }

    bytes_read += this_read;
    buf        += this_read;
  }

  return bytes_read;
}