Iweb Getresponse | developer.brewmp.com Iweb Getresponse | developer.brewmp.com

Developer

Iweb Getresponse

Forums:

Hi ALl
I have written code some what mentioned bellow to connect a webpage and return me the result.Most of the time it gives me the result. But some time it does not and the system hangs . The code is some what like the one bellow

if (ISHELL_CreateInstance(pLogin->a.m_pIShell, AEECLSID_WEB, (void**)(&pLogin->m_pIWeb)) != SUCCESS)
{
WebCleanup(pLogin);
return ;
}

if (url)
{
//WriteLine(pLogin,url);
pLogin->m_BodyBuffer = NULL;
pLogin->m_BodySize = 0;
pLogin->m_BodyAllocSize = 0;

CALLBACK_Init(&pLogin->m_Callback, WebReadCB, pLogin);
IWEB_GetResponse(pLogin->m_pIWeb,
(pLogin->m_pIWeb, &pLogin->m_pIWebResp, &pLogin->m_Callback,
url,WEBOPT_HANDLERDATA, pLogin,
WEBOPT_HEADER,WEBOPT_STATUSHANDLER,
WebStatusNotification,WEBOPT_METHOD,WEBOPT_END));
}
else
{
DisplayText(pLogin, "Error-URl not Found");
WebCleanup(pLogin);
return ;
}
If I use break point it shows it goes through the if part of the code. but it does not go to WebReadCB Method which is the call back method. Neither it goes to the WebStatusNotification. Remember it happens only some time after which the emulator hang. Most of the time it works fine
I Usually passed the url like pramod.com?name=pramod&id=100
Could any body tell me what could be possible reason
Regards
Pramod

Well, from the code segment nothing seem to be obvious. One quick thing to check would be, "url" string. How are you allocating the url string? If it is on stack then it would be problematic.
When your emulator hangs, did you try to break execution to check if it is getting hanged in your code itself. Check if you are hitting memory limit or you have any memory leak.

Well, from the code segment nothing seem to be obvious. One quick thing to check would be, "url" string. How are you allocating the url string? If it is on stack then it would be problematic.
When your emulator hangs, did you try to break execution to check if it is getting hanged in your code itself. Check if you are hitting memory limit or you have any memory leak.

Thanx ruben
OK. I am creating a dynamic url each time on selection of the user. But What I feel might be cause of hangiong emulator may be memory leak or Hitting memory limit may not be an option as the emulator show some memory free when it hangs. Is there any way to check memory leaks in vc++
Regards
Pramod

Thanx ruben
OK. I am creating a dynamic url each time on selection of the user. But What I feel might be cause of hangiong emulator may be memory leak or Hitting memory limit may not be an option as the emulator show some memory free when it hangs. Is there any way to check memory leaks in vc++
Regards
Pramod

Possible cause cud be :
1) U r freeing "url " before yr callback/webstatus function gets invoked. Note that url shud remain in memory untill yr callback function gets invoked
2) U might not freeing the memory after yr callback func is invoked..so after no. of successfull call to callback function it hangs!
Hope this may help to figure out the problem!!
regds,
Nilesh

Possible cause cud be :
1) U r freeing "url " before yr callback/webstatus function gets invoked. Note that url shud remain in memory untill yr callback function gets invoked
2) U might not freeing the memory after yr callback func is invoked..so after no. of successfull call to callback function it hangs!
Hope this may help to figure out the problem!!
regds,
Nilesh

Hi Nilesh
Thanx for the reply. But I dont think It might be the case. Most of the time the emulator stops at WebStatusNotification function which provides the status of the IWEB. It stuck after trying to getresponse from the web. I have used DBGPRINTF and Found that It stuck of at the following line of the code
static void WebStatusNotification(void *pNotifyData, WebStatus ws)
{
strLogin* pLogin = (strLogin*)pNotifyData;
int StatusLine = 1;
char* str=NULL;
//int16 nResID = 0;
switch (ws)
{
case WEBS_CANCELLED:
str="URL Cancelled";
break;
case WEBS_GETHOSTBYNAME:
str="Get host by name";
break;
case WEBS_CONNECT:
str="Connecting Website";
break;
case WEBS_SENDREQUEST:
str="Sending Request";
break;
case WEBS_READRESPONSE:
str="Reading Response"; //executino of stops ater this line
break;
case WEBS_GOTREDIRECT:
str="Redirecting Webpage";
break;
case WEBS_CACHEHIT:
str="Reading from cache";
break;
}
if (str!=NULL)
DisplayText(pLogin,str);
DBGPRINTF(str);
}

Hi Nilesh
Thanx for the reply. But I dont think It might be the case. Most of the time the emulator stops at WebStatusNotification function which provides the status of the IWEB. It stuck after trying to getresponse from the web. I have used DBGPRINTF and Found that It stuck of at the following line of the code
static void WebStatusNotification(void *pNotifyData, WebStatus ws)
{
strLogin* pLogin = (strLogin*)pNotifyData;
int StatusLine = 1;
char* str=NULL;
//int16 nResID = 0;
switch (ws)
{
case WEBS_CANCELLED:
str="URL Cancelled";
break;
case WEBS_GETHOSTBYNAME:
str="Get host by name";
break;
case WEBS_CONNECT:
str="Connecting Website";
break;
case WEBS_SENDREQUEST:
str="Sending Request";
break;
case WEBS_READRESPONSE:
str="Reading Response"; //executino of stops ater this line
break;
case WEBS_GOTREDIRECT:
str="Redirecting Webpage";
break;
case WEBS_CACHEHIT:
str="Reading from cache";
break;
}
if (str!=NULL)
DisplayText(pLogin,str);
DBGPRINTF(str);
}