I strongly recommend that you get the palm web applications written by ben
combee et al.

other wise here is the code that you will need in order to capture a web
site

hope this helps

colleen

#define SERVER_URL "http://www.palm.com/webbrowser/";
static Err CacheURL()
{
    MemHandle   inetHan, inetSockH;
        Char            *responsePtr;
        UInt32 value=0;
        INetURLInfoType inetinfo;
    UInt16 AppINetRefnum=0,cfgIndex;
        UInt32          totalBytes, bytesRead, reqestedBytes=0, offset = 0;
  UInt32        downloadSize = MAX_RESPONSE_SIZE;
  UInt32        algorithm = ctpConvNone; /* no conversion */
   DmSearchStateType searchState;
   UInt16 cardNo;
   LocalID dbID;
   Err error;
   DmOpenRef localRef;
   INetConfigNameType cfgName  = { inetCfgNameCTPDefault };


        error = DmGetNextDatabaseByTypeCreator(true,&searchState,
                sysFileTApplication,sysFileCClipper, true,
                &cardNo, &dbID);

        if (error)
        {
                return error;
        }
                localRef =
DmOpenDatabaseByTypeCreator(sysFileTApplication,sysFileCClipper,
dmModeWrite);
                if (!localRef)
                        return DmGetLastErr();
                /* allocate memory to hold the file retrieved */
                responsePtr = MemPtrNew(MAX_RESPONSE_SIZE);
                if (error)
                        return false;

                /* choose whether to use wireline connection or wireless */
                error = INetLibConfigIndexFromName(AppINetRefnum, &cfgName,
                                        &cfgIndex);
                if (error)
                        return false;

        /* open the library */
                error = INetLibOpen(AppINetRefnum, cfgIndex, 0,localRef ,  
reqestedBytes,
&inetHan);
                if (error)
                        return false;
                /* Set the default settings for buffer size and conversion
                 * algorithm to be used */
            error = INetLibSettingSet(AppINetRefnum, inetHan,
                        inetSettingMaxRspSize, (UInt8*)&downloadSize,
                        sizeof(downloadSize));
                if (error) return false;
                error = INetLibSettingSet(AppINetRefnum, inetHan,
                                inetSettingConvAlgorithm, (UInt8*)&algorithm,
                sizeof(algorithm));
                if (error) return false;
                error = INetLibSettingSet(AppINetRefnum, inetHan,
                                inetSettingCacheSize, (UInt8*)&algorithm,
                sizeof(algorithm));
                if (error) return false;

                /* start the fetch of URL. This command merely "starts" the
                 * the communication, you should read the result explicitly
                 * from the socket by making another call.
                 */
                error = INetLibURLOpen(AppINetRefnum, inetHan,
                                        (UInt8 *)SERVER_URL,(UInt8 *)SERVER_URL, 
&inetSockH,
                                        evtWaitForever, inetOpenURLFlagKeepInCache);
                if (error) return false;


                reqestedBytes = 4096;
                totalBytes = bytesRead = 0;
                do
                {
                        /* read something from the socket - blocking call */
                error = INetLibSockRead(AppINetRefnum, inetSockH,
                                                responsePtr + totalBytes,
                                                reqestedBytes - totalBytes,
                                                &bytesRead, 20 * SysTicksPerSecond());

                        /* update our pointers for the next write */
                        offset += bytesRead;
                        totalBytes += bytesRead;

        } while (
                                        (bytesRead != 0) && /* until the peer is done 
*/
                                        !error &&                       /* or until 
the first error */
                                        /* or we downloaded     too much already */
                                        (totalBytes < MAX_RESPONSE_SIZE)
                                );

                if (totalBytes > 0) /* got something? */
                {
                        responsePtr[totalBytes] = 0;
//                      FrmCustomAlert(ServerResponse, responsePtr, NULL, NULL);
                }
                else
//                      FrmCustomAlert(ConnectionError, "No response from server", 
NULL, NULL);
                /* final cleanup code */
                error = INetLibURLGetInfo (AppINetRefnum,inetHan, /*(UInt8 
*)responsePtr
*/ (UInt8 *)SERVER_URL ,&inetinfo);
                if (error) return false;
                MemPtrFree(responsePtr);
                error = DmCloseDatabase (localRef);
                if (error) return false;
                INetLibSockClose(AppINetRefnum, inetSockH);
                INetLibClose(AppINetRefnum, inetHan);

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Yogaramanan
Sent: Tuesday, May 21, 2002 10:39 PM
To: Palm Developer Forum
Subject: INetLib.............?


Is it possible to connect to internet through palm which can be earlier than
m505 ? if so how ?

I need to connect to internet and just get the html page in string format.
it is not intended to display the page to the user.
how to do and what are the requirements for this ? pls help !
can any body provide a little source code demonstrating this ?
thanks in advance.

by
yogaramanan


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


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

Reply via email to