I used the code below to retrieve a binary gif image (although I didn't try to
display it).  The TCP/IP (or UDP) read command was always meant to fetch into a
byte array, that way it wouldn't matter what you were trying to download.  This
case is no different.  When you issue the "GET" command through the URLOpen or
through the set of socket open steps that you've worked with before Jon it's
exactly the same.  However, you should use a byte array to retrieve the data when
you expect it to be anything but a string.  The byte array doesn't require a '\0'
at the end of the line for termination.

If you were retrieving a large amount of data and weren't sure of the size, I'd
create a copy routine that would resize the buffer using a handle and copy the
data from the array into the new buffer along with the old data.  Unfortunately I
don't believe that the Palm OS supports the memcpy function which would
automatically do this for you.  It does support memSet which should be used to
set the buffer to the value zero before using the request below.

I passed http://www.dive-site.com/images/tools2.gif as the data to fetch.  Also,
as I informed Jon earlier you should always copy data that you are sending over
the wire into a byte buffer.  Most people assume they can call (Byte *)"GET",
while this works sometimes it doesn't work all the time.  Instead I do the
following:

Byte transferType[5];
StrCopy((char *)&transferType,"GET");

now pass transferType instead of (Byte *)"GET"

// Call from application
Byte buffer[255];
short size = 255;

_wirelessManager.Read((Byte *)&buffer,&size);

// Actual function
int WirelessManager::Read(Byte *retValue, short *size)
{
 Err err;

 DWord bytesIn = 1;
 bool  firstRun = true;

 err =
INetLibSockRead(_libRefNum,_sockH,(VoidPtr)retValue,*size,&bytesIn,SysTicksPerSecond());


 *size = bytesIn;

//size and bytesIn are used separately in the function, since one is a pointer I
used two different variables
// to insure the two don't clash when the function is actually called.

 return err;
}

Hope this helps.

Scott Lopez
Jon Baer wrote:

> Not asking "give away their secret" but Id like to ask you how this was
> accomplished and what the steps a,b,c are to using INetLib to retreive
> arbitrary data (ie, not HTML or text) but lets say small binary java classes.
> How does one make the connection to read it?
>
> - Jon
>
> David Fedor wrote:
>
> > >Does the Palm have the ability to load new programs via iMessenger?
> >
> > iMessenger does not have this ability.  But the ability to do this sort of
> > thing is available by using the INetLib from a C application.  For example,
> > palmgear.com has written an application to install prcs over the air.
> >
> > -David Fedor
> > Palm Developer Support
>
> --
> ===============================
> DigitalAnywhere.com
> www.digitalanywhere.com
> [EMAIL PROTECTED]

Reply via email to