I should add that INetLibOpen doesn't return an error, and wirelessdata
was set to null before passing into that function. I know technically
derefrencing the handle might not be valid, but in all the apps I have
that work, it's something other than null, and in my app it is null. Could
be coincidence, but....
MemHandle gwirelessport, gwirelesssocket;
UInt16 gwirelessport;
void Example ()
{
Err err;
UInt16 configindex;
Char config[15] = ".CTPDefault";
Char putverb[6] = "GET";
Char request[256] = "http://123.123.123.123/";
gwirelessport = 0;
gwirelessdata = NULL;
err = SysLibFind("INet.lib", &gwirelessport);
err = INetLibConfigIndexFromName (gwirelessport,
(INetConfigNamePtr)config, &configindex);
err = INetLibOpen (gwirelessport, configindex, 0, NULL, 0,
&gwirelessdata);
err = INetLibSockOpen (gwirelessport, gwirelessdata,
inetSchemeHTTP, &gwirelesssocket);
err = INetLibSockHTTPReqCreate (gwirelessport, gwirelesssocket,
(UInt8 *)putverb, (UInt8 *)request, NULL);
err = INetLibSockHTTPReqSend (gwirelessport, gwirelesssocket, NULL, 0,
1000);
// This is where the emulator complains
}
Interestingly, if I use a DNS name instead of an IP address, the emulator
doesn't complain! But then if I try to make a 2nd request, it can't get a
socket...argh!
On Mon, 17 Jul 2000, Fitzpatrick, Joe wrote:
> First off, you should be checking the return values of INetLibOpen and
> INetLibConfigIndexFromName.
>
> Second, you might be on a wild goose chase with dereferencing the handle.
> It is a handle, what it points to, or does not point to is not the app's
> business.
>
> Basically, start with a handle and set it to NULL:
>
> HANDLE IHandle = NULL;
>
> Pass the address of the handle (ex. &IHandle) in to INetLibOpen. If
> INetLibOpen returns 0, the handle will not be null. Beyond that, you can
> make no safe assumptions.
>
> Note, this is appears to be the case in your message:
>
> WirelessData - 0x0001A87E - Your variable, a Pointer to a handle
> - *WirelessData - 0x800015C0 - A handle, not NULL
> - **WirelessData - 0 - What the handle points to (off limits)
>
> We can't be sure you got a valid handle from INetLibOpen because you did not
> clear the handle to NULL before making the call. However, if you can
> 'mostly' use the library things are probably initialized correctly. If
> things are initialized correctly, your memory access problems are probably
> caused by something else in your program.
>
> Good Luck
> -jjf
>
> -----Original Message-----
> From: Chris DiPierro
> To: Palm Developer Forum
> Sent: 7/17/00 3:59 PM
> Subject: INetLibOpen Problems (Causes direct mem accesses)
>
> If I do something like this:
>
> Err NetPalm7Init (UInt16 *WirelessPort, MemHandle *WirelessData)
> {
> Char config[15]=".CTPDefault";
> UInt16 configindex;
> UInt32 param;
> Err err;
> UInt32 set;
>
> err = SysLibFind("INet.lib", WirelessPort);
> if (err) {
> *WirelessPort = 0;
> }
> else {
>
> INetLibConfigIndexFromName(*WirelessPort,(INetConfigNamePtr)config,
> &configindex);
> INetLibOpen(*WirelessPort, configindex, 0, NULL,
> 0,WirelessData);
>
> }
> return (err);
> }
>
> WirelessData doesn't get initilized right (compared to sample apps I've
> used). I can see no differnce between what I'm doing and what they're
> doing, but for instance, if I look at WirelessData in the CW debugger, I
> see:
>
> WirelessData - 0x0001A87E
> - *WirelessData - 0x800015C0
> - **WirelessData - 0
>
> However, in other apps, the **WirelessData becomes a value...
>
> I can use the INetLib mostly correctly after this, but the emulator
> yells
> at me about direct memory accesses on sockets later on and it's causing
> some real device problems.
>
> What am I doing wrong????
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palmos.com/dev/tech/support/forums/
>
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/