I have a netlibreceive loop setup to accept until it receive's nothing. The
problem is that on the last receive attempt, it always goes to the timeout. I
want to implement netlibselect, but am not fully sure how to. I've attached a
code chunk below. Can someone assist in adding netlibselect functionality so
that it will detect a timeout and just skip the netlibreceive command instead
of waiting the whole timeout period. You'll notice a second netlibreceive that
is commented out. What i found was that in some cases, on certain carriers,
the treo would timeout even if there was pending data, so this second call was
an attempt to get that data:
do {
bytesRead = NetLibReceive(netinfo->netlibrefnum,
netinfo->socketrefnum,(void *)pBuffer, totalBytesToRead, 0, NULL, 0,
netinfo->timeout, pErr);
/* //if we timeout and have more to read, try again
//I put this here because on sprint phones, we tend to timeout a lot more.
//Notice on this second receive call i multiply the timeout by 2
if ((*pErr == netErrTimeout) && (netinfo->maxbytestoread + 1 ==
totalBytesToRead))
{
bytesRead = NetLibReceive(netinfo->netlibrefnum, netinfo->socketrefnum,
(void *)pBuffer, totalBytesToRead, 0, NULL, 0, netinfo->timeout*2, pErr);
}
*/
if (*pErr == errNone && bytesRead > 0)
{
// Update counters: how much remains, how much read,
// and where the next data read should go.
totalBytesToRead -= (UInt16)bytesRead;
*totalBytesRead += (UInt16)bytesRead;
pBuffer += bytesRead;
}
} while (bytesRead > 0 && totalBytesToRead > 0);
Thanks for your help!
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/