Actually, it's a feature. :-)
Seriously though, it's a consequence of having a limited number of
sockets available on the device, combined with the characteristics of
the TCP protocol.
What's happening is that when you close the socket there is a
sequence of events that happen between the two sides to shut down the
connection. After both sides have done their part, the socket remains
around for a while to catch any stray TCP segments that may have been
delayed/duplicated during the session. Once sufficient time has gone
by to guarantee that no additional segments may be received then the
socket is reclaimed.
This is standard TCP behavior, the difference here is that Palm OS
has a very tight limit on the number of sockets that can be in this
state.
Setting linger to zero will help, but won't eliminate the delay.
Likewise, ensuring that both sides of the session properly close
their connection will also help, but won't completely eliminate the
delay.
If you've got control of both sides of the session, and if it can be
reasonably done I'd recommend changing your app so that it does more
per TCP connection. This is similar to passive mode for FTP in some
ways, or multi-get HTTP.
Cheers,
Bruce Thompson
Strategic Partner Engineering
Palm, Inc.
>On 10-Jul-2000 DCU wrote:
>
>> I am developing Socket applications for the palmos. I am currently having
>> problems with closing a socket, as they do not seem to close with the
>> NetLibCloseSocket command and this eventually creates a problem after 16
>> data transmissions occur. The problem/error they I have is Too Many TCP
>> connections. I am not sure why I get this error since I close the
>> connection after every transmission. There should only be one connection
>> open at any given time.
>
>It is a PalmOS bug. The work-around is to turn off lingering.. actually the
>bug is that turning off lingering requires you to turn it on with a time of 0
>:)
>
> NetSocketLingerType linger;
>
> linger.onOff = true;
> linger.time = 0;
> if (NetLibSocketOptionSet(AppNetRefnum, sock, netSocketOptLevelSocket,
> netSocketOptSockLinger, &linger, sizeof(linger), AppNetTimeout,
> &errno) != 0) {
> /* error */
> }
>
>
>
>/* Chris Faherty <[EMAIL PROTECTED]> */
>/* Your Stock has crashed - you must now restart your system */
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe, please
>see http://www.palmos.com/dev/tech/support/forums/
--
------------------------------------------------------------------------------
Bruce Thompson | "Pinkie! Are you pondering what I'm pondering?"
Software Engineer | "I think so Brain, but if they called them Sad
Partner Engineering | Meals kids wouldn't buy them!"
Palm, Inc.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/