Does anyone know how to close the NetLib if it is opened by another
application? In other words, how do I detect whether a network connection is
currently made?

The way I see it, calls to NetLibOpenCount and NetLibClose only work after a
call to NetLibOpen. However, a call to NetLibOpen will try to connect if
there isn't already a connection. So if I don't want to open a connection,
just close it, I can't find out whether it is open, nor close it, without
risking opening it.

In OS 4.0 there is a sysNotifyNetLibIFMediaEvent, but how is this done in
pre-OS4.0?


Here is code that will do what the comments say if there is a connection
established by another app, but NetLibOpen has not been called by this app
since it started. (It works fine after a call to NetLibOpen.)


    // OK. Returns 0 and ref is set to 4.
    err = SysLibFind(comLibName, &netlibRefnum);

    if (!err) {
        // Returns 0, but count is set to 0.
        err = NetLibOpenCount(netlibRefnum, &count);

        for (i = 0; i < count; i++) {
            err = NetLibClose(netlibRefnum, true);
        }
    }


Matt



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to