emulator/cpu/processor.c
ssize_t
elliott803_receive(elliott803_t *proc, char *buffer, size_t buffer_size) {

  for (;;) {
    errno = 0;
    ssize_t n = recv(
      proc->client_socket, buffer, buffer_size, MSG_WAITALL | MSG_DONTWAIT);
    if (-1 == n) {
      // if interrupted system call, just retry
      if (EINTR != errno) {
        // fprintf(stderr, "select error: %s\n", strerror(errno));
        return errno; // negative value
      }
      continue;
    }

    return n;
  }
}
// receive a response
// returns:
//   positive: bytes received
//   negative: error code
receive a response
returns:
positive: bytes received
negative: error code
receive a response returns : positive : bytes received negative : error code
ssize_t
elliott803_receive(elliott803_t *proc, char *buffer, size_t buffer_size) {
  for (;;) {
    errno = 0;
    ssize_t n = recv(
      proc->client_socket, buffer, buffer_size, MSG_WAITALL | MSG_DONTWAIT);
    if (-1 == n) {
      if (EINTR != errno) {
        return errno; 
      }
      continue;
    }
    return n;
  }
}
ssize_t elliott803_receive ( elliott803_t * proc , char * buffer , size_t buffer_size ) { for ( ; ; ) { errno = 0 ; ssize_t n = recv ( proc -> client_socket , buffer , buffer_size , MSG_WAITALL | MSG_DONTWAIT ) ; if ( -1 == n ) { if ( EINTR != errno ) { return errno ; } continue ; } return n ; } }
receive a response
returns:
positive: bytes received
negative: error code
receive a response returns : positive : bytes received negative : error code
// if interrupted system call, just retry // fprintf(stderr, "select error: %s\n", strerror(errno)); // negative value