samples/straws/distribution.c
/* Receive a socket's name */
Receive a socket's name
Receive a socket ' s name
int recv_name (SOCKET sock, char *out) {
  char len;
  if (recv (sock, &len, 1, 0) != 1) {
    fprintf (stderr, "Failed to recv name length\n");
    return 1;
  }
  int pedantic = len;
  if (pedantic > MAX_NAME) {
    fprintf (stderr, "Name length %d too large\n", (int)len);
    return 2;
  }
  int recvd = 0;
  while (recvd < len) {
    int r = recv (sock, out + recvd, len - recvd, 0);
    if (r == -1) {
      fprintf (stderr, "Failed to read name\n");
      return 3;
    }
    recvd += r;
  }
  return 0;
}
int recv_name ( SOCKET sock , char * out ) { char len ; if ( recv ( sock , & len , 1 , 0 ) != 1 ) { fprintf ( stderr , " \n " ) ; return 1 ; } int pedantic = len ; if ( pedantic > MAX_NAME ) { fprintf ( stderr , " \n " , ( int ) len ) ; return 2 ; } int recvd = 0 ; while ( recvd < len ) { int r = recv ( sock , out + recvd , len - recvd , 0 ) ; if ( r == -1 ) { fprintf ( stderr , " \n " ) ; return 3 ; } recvd += r ; } return 0 ; }
Receive a socket's name
Receive a socket ' s name
/* Receive the length */