On 26-May-99 Ion Popescu wrote:
> I am writing an app that uses NetLib. After 16 successful connections,
my
> app gets "netErrTooManyTCPConnections" (error: 0x124F) from
> NetLibSocketOpen() call. The figure 16 gives me a feeling that I am
> missing an unlock/free of one of the network resources. I have checked
my
This should be on a FAQ somewhere since almost all net developers on the
Palm system run into it eventually. The problem is that, by default, a
socket is kept in a semi-open state after you close it for a short period
of time. This allows the socket to shut down the remote connection
properly. The behavior is called "lingering". Palm's netlib allocates only
16 sockets for any kind of use. So if you are rapidly opening and closing
sockets, the lingering sockets will soon use up all the available sockets
and you will not be able to open any more until the linger time is used up.
If you wait a while you will notice that you can again use sockets...
Anyway, the common solution is to disable linger using the socket option of
that name.
>I have found through experimentation that if you don't call NetLibClose()
>with true after a NetLibOpen() failure that you can end up in a
>quasi-connected state whereby you have to power-down the unit before
trying
>again.
The way to deal with this situation is to call NetLibConnectionRefresh.
This will bring up the physical connection if it has gone down without
forcing you to shutdown and restart the whole stack.
--- Gavin