library/socket.c
ssize_t readn(int fd, void *vptr, size_t n)
{
  size_t  remaining;
  ssize_t received;
  char    *ptr;

  remaining = n;
  ptr = vptr;
  while (remaining > 0) {
    received = read(fd, ptr, remaining);
    if (received <= 0) {
      if (received < 0)  warn("read");
      return received;
    }
    remaining -= received;
    ptr += received;
  }
  return n;
}
// Advanced Programming in the Unix Environment, Program 12.13
Advanced Programming in the Unix Environment, Program 12.13
Advanced Programming in the Unix Environment Program 12 . 13
ssize_t readn(int fd, void *vptr, size_t n)
{
  size_t  remaining;
  ssize_t received;
  char    *ptr;
  remaining = n;
  ptr = vptr;
  while (remaining > 0) {
    received = read(fd, ptr, remaining);
    if (received <= 0) {
      if (received < 0)  warn("read");
      return received;
    }
    remaining -= received;
    ptr += received;
  }
  return n;
}
ssize_t readn ( int fd , void * vptr , size_t n ) { size_t remaining ; ssize_t received ; char * ptr ; remaining = n ; ptr = vptr ; while ( remaining > 0 ) { received = read ( fd , ptr , remaining ) ; if ( received <= 0 ) { if ( received < 0 ) warn ( " " ) ; return received ; } remaining -= received ; ptr += received ; } return n ; }
Advanced Programming in the Unix Environment, Program 12.13
Advanced Programming in the Unix Environment Program 12 . 13