I'm working on a TCP/IP Palm app that opens and closes *a lot* of sockets.
Unfortunately I'm running into a problem such that after approximately 15
"transactions", the next time I try to call NetLibSocketConnect() after
creating the socket (without any error) it returns
"netErrTooManyTCPConnections" (The app works fine in the emulator, but not
with the Palm modem).
I close all my sockets the following way:
NetLibSocketShutdown(AppNetRefnum, sock, netSocketDirBoth, -1, &errno);
NetLibSocketClose(AppNetRefnum, sock, -1, &errno));
I have tried setting the socket's so_linger option to something reasonable
(say a minute, I *cannot* use a linger time of 0) but it doesn't appear to
work as I would expect. Given my reading and understanding of Berkeley
sockets, setting a linger time and closing the socket should block the app
until either the socket closes properly, or it should block and forcefully
close the socket when the linger time expires. But I basically am still
getting the "netErrTooManyTCPConnections" error. I don't know if this is a
bug in my understanding of sockets, or the network stack.
I have also tried uninitializing the network stack (without hanging up the
modem) and reinitializing it, but that doesn't work either.
Unfortunately since Palm doesn't currently distribute the source to NetLib
(hint, hint ;-) I'm having trouble figuring out exactly why this is occuring
and what a potential solution might be.
Any suggestions would be most appreciated as I'm completely stumped.
Thanks in advance,
Alexander