> At 4:53 PM -0800 2000/01/17, Alexander Hinds wrote:
> >any idea if this will be fixed in a future version of the os?  ;-)
>
> Well, it's not really "broken" per se... but it is an annoyance.
>
> Closed sockets conventionally stick around for a few minutes to
> complete the last transfer of data pending (if any, in either
> direction) before the socket is closed. These "lingering"
> connections require memory and resources which are extremely
> limited on a Palm OS device, which has a hard-coded limitation of
> 4 simultaneously active sockets. A lingering socket is an active
> socket as far as the IP stack is concerned.
>
> Setting the SO_LINGER option to 0 is the correct work-around, but
> may have an unavoidable side-effect of closing the socket too
> abruptly for the other end of the connection. The other end may
> see the close as an "error" as opposed to a "normal" socket
> close, which may or may not have reliably completed the last data
> transfer transaction. YMMV.

J-

Hmm...I don't want to appear argumentative esp. since I'm hardly an IP
expert and I really do appreciate your reply (and *please* correct me if I'm
wrong), but...classically (ie. according to "the books" I've read), setting
a linger time of, say 20 seconds, should *block* your app and if the socket
doesn't close after 20 seconds, then it should force the socket to shutdown
(regardless of any pending I/O), recyle the resources, and return control to
your app.  My (extended) experimentation with the current NetLib suggests
that Palm sockets don't behave this way (unless your linger time is 0).  And
another thing I've wondered about:  the NetLibSocketClose() function takes a
timeout parameter.  But setting the timeout to infinity doesn't seem to
recycle the resources the socket is using - so, I'm somewhat puzzled as to
what exactly that timeout parameter does.

I understand the limited resources of the PalmOS.  But there should be *some
way* of blocking your app until the socket *really is* closed.  As you
mentioned, setting a linger time of "0" causes a lot of servers to get
really upset and is not useful at all in the context of my current project,
or many others that I might contemplate.

Furthermore, what's seems really odd is this:  when I close the socket I can
immediately allocate another socket (despite the linger problem).  But it's
when I call NetLibSocketConnect() that I get an error.  One would think that
if the socket were really lingering that NetLibSocketOpen() would fail, not
the former.  Moreover, I tried something silly just to see if it would work:

        sock = NetLibSocketOpen(...);
        for (int x = 0; x < infinity;  ++x){
                if (NetLibSocketConnect(...) == 0)
                        break;
        }

but it didn't appear to work at all.  hmm....

It would seem to me (at least IMHO) until this issue resolved that writing
more involved and reliable TCP/IP apps will be extremely difficult on a Palm
device.  That's just my 2 cents, for whatever they're worth ;-)

Thanks again for your help,

Alexander


Reply via email to