Hello everyone,
I'm writing an application for the Symbol 1740 which uses NetLib to
communicate with the outside world via a wireless ethernet connection, and
I'm encountering some weird problems I hope someone has seen before.
I'm using the following sequence of calls to do this - SysLibFind,
NetLibOpen, NetLibGetHostByName, NetLibSocketOpen, NetLibSocketBind,
NetLibSocketConnect, NetLibSocketSend, NetLibSocketReceive,
NetLibSocketShutdown, NetLibSocketClose, and NetLibClose.
Everything works fine, providing there are no errors. If one of the calls
generates an error of some description, like the Connect times out or
something, then the app will generate a Fatal Exception when it quits.
Here's a snippet with an optionally introduced error to make it fail -
Err errCode = ::SysLibFind ("Net.lib", &AppNetRefnum);
if (errCode != 0)
{
throw PSocketExceptionFactory::MakeException ("SysLibFind", errCode);
}
Word ifErrCode = 0;
errCode = NetLibOpen (AppNetRefnum, &ifErrCode);
if (errCode != 0 || ifErrCode != 0)
{
throw PSocketExceptionFactory::MakeException ("NetLibOpen", errCode);
}
NetSocketRef socket = NetLibSocketOpen
(AppNetRefnum,
netSocketAddrINET, netSocketTypeStream,
netSocketProtoIPTCP, AppNetTimeout, &errCode);
if (socket == -1)
{
throw PSocketExceptionFactory::MakeException
("NetLibSocketOpen", errCode);
}
// uncomment this to introduce failure, and a crash on exit
// socket = -1;
if (NetLibSocketClose
(AppNetRefnum, socket, AppNetTimeout, &errCode) == -1)
{
throw PSocketExceptionFactory::MakeException
("NetLibSocketClose", errCode);
}
NetLibClose (AppNetRefnum, false);
I'm copying this to the Palm Dev List and also to support at Symbol, in the
hope that someone can help out. Of course the workaround is simply to
connect only to sites that are up and responsive all the time, but that's
not always available....
Thanks in advance.
Jason Proctor
Sr Engineer
Bear River