receive

This method waits on the socket to receive the data.

Signature
int RiCOSSocket_receive (RiCOSSocket *const me, 
   char *buf, int bufLen);
Parameters
me

The RiCOSSocket object

buf

The string buffer in which data will be stored

bufLen

The length of the buffer

Returns

The method returns one of the following values:

Example
int RiCOSSocket_receive(RiCOSSocket * const me, 
   char * buf, int bufLen)
{
   int bytes_read = 0;
   int n;

   if (me==NULL) return -1;

   while (bytes_read < bufLen) {
      n = recv(me->theSock, buf + bytes_read, 
         bufLen - bytes_read,0);
      if (SOCKET_ERROR == n) {
         if (errno == EINTR) {
            continue;
         }
         else {
            return -1;
         }
      }
      else {
         if (0 == n) { /* Connection closed. */
            return -1;
         }
      }
      bytes_read += n;
   }
   return bytes_read;
}

Feedback