Bruce Thompson wrote:
> The answer is a resounding YES! The ExgSend function can return values
>other
>than 0 or the full count. The fact that the built-in apps are writeen to
>assume
>it's all or nothing is frnakly a bug in the built-in apps.
I was really hoping you were going to say this was a documentation error
and the ExgSend function didn't really work that way. This makes using
ExgSend really painful. Most people will probably need to make a wrapper
function to handle this problem (as below).
FixedExgSend(ExgSocketPtr socketPtr, void * bufPtr, ULong bufLen, Err *
errorPtr)
{
Byte * xBufPtr;
ULong bytesRemaining;
ULong bytesSent;
ULong bytesSentTotal;
xBufPtr = (Byte *) bufPtr;
bytesRemaining = bufLen;
bytesSentTotal = 0;
*errorPtr = 0;
while (bytesRemaining)
{
bytesSent = ExgSend(socketPtr, xBufPtr, bytesRemaining, errorPtr);
bytesSentTotal += bytesSent;
bytesRemaining -= bytesSent;
xBufPtr += bytesSent;
if (*errorPtr)
break;
}
}
I don't understand why this wasn't implemented inside ExgSend. It seems
like a design error to force every caller to duplicate this code rather
than putting it in ExgSend once. Note that EVERY piece of Palm source code
I've seen which uses ExgSend assumes that the transmit does all or nothing.
I would guess that most 3rd party developers will follow this lead and
implement it incorrectly as well.
>You should always write your app to assume that ExgSend may need
>multiple calls and to keep the event loop running between calls to ExgSend.
I don't understand this comment. It was my impression that ExgSend had its
own event loop which is used to update the progress dialog and check for
taps in the CANCEL button. Wouldn't it be a mistake for the application to
process events between ExgSends? For example, what would I do with a button
press in the CANCEL button?
So are you going to report the bugs in the built-in apps or should I? It's
present in the 3.0 versions of the Address, DateBook, Memo and Todo
applications as well as the Beamer example. I have not seen any newer
sources, so I don't know if it has been fixed.
Bill Goodman
Cyclos