At 11:11 AM -0500 2/18/02, Matt Hebley wrote:
>Keith
>
>I understand this mainly from hearsay, and personal experience. In
>Greg Winton, Palm OS Network Programming, O'Reilly, p199, it says
>"On Windows and Max machines, the host's sockets API do not support
>timeouts, so this parameter is ignored."
This was true for a couple of functions until Poser 3.1. From _OldNews.txt:
* Implemented support for the timeout values passed to NetLibReceive
and NetLibSend. Previously, these values were ignored, leading to
hangs or overly-long timeouts on the desktop that wouldn't appear on
the device. [Hiroyuki Okamoto]
However, I'm not aware of any other places where timeouts are ignored.
>It then goes on to say that POSE appears frozen until the call
>"times out." I asked at PalmSource and nobody seemed to know too
>much about it, except that there used to be a bug that had been
>fixed.
This part is true. The CPU emulation thread (which is handling the
socket call) is blocked on on the socket call. If the UI thread
needs to do something (like update the screen), it needs to first
synchronize with the CPU thread. But with the CPU thread blocked on
the socket, the UI thread blocks on the CPU thread, and general
blockage ensues.
>In my code, I set the timeout to 20 seconds which appears to be the
>case on a real device (I haven't actually set up a scenario that
>will take forever and timed the timeout). With POSE the same code
>often times out on the host stack in what I estimate to be 2 seconds
>(definitely way less than 20 seconds), but doesn't seem to do the
>same using the NetLib stack. I guess have never seen it written that
>there is a two second timeout... and I also haven't spent that much
>time investigating since it didn't seem to be a big obstacle.
I couldn't say what was going on there, unless some condition is
causing the socket call to exit early. Have you examined return
values to see if there's anything there (they probably just indicate
a timeout occurred, right)?
Perhaps there's a problem with the way I convert ticks to
microseconds? Here's my code:
// Convert ticks to microseconds.
hostTimeout.tv_sec = timeout / sysTicksPerSecond;
hostTimeout.tv_usec = (timeout % sysTicksPerSecond) *
(1000000 / sysTicksPerSecond);
hTp = &hostTimeout;
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/