You also need to check the value of error.  Here is a piece of code I use 
that is very reliable.  It uses NetLibReceive, but its the same principal. 
I don't know if you are using blocking or non-blocking sockets, but this 
will work for either.

UInt16 chunkSize = 512;
do {
  // Loop until all data is received
  result = NetLibReceive(netInfo.netLibRefnum, netInfo.netSocketRef, rcvP, 
chunkSize, 0, NULL, 0, netInfo.netTimeout, &err);
  // Non-blocking errors, pause a quarter second then continue
  if (err == netErrWouldBlock || err == netErrSocketBusy) {
    SysTaskDelay (SysTicksPerSecond() / 4);
    err = 0;
    result = 1;
  } else {
    if (result != -1 && !err) {
      bytesReceived += result;
      rcvP += result;
    }
  }
} while (result && result != -1 && !err);

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to