W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2003

[www-lib] <none>

From: Sandesh Anvekar <sanvekar@controlnet.co.in>
Date: Sat, 8 Feb 2003 12:08:13 +0530
Message-ID: <011701c2cf3c$ac9fb3d0$9b0aa8c0@sandesh>
To: <www-lib@w3.org>
Hi All,

    I have written a piece of code something like this and I am calling the function xrayhttpget after a fixed time interval repeatetively .But I have encountered a problem in this
Suppose I give a valid uri of some html document and as I said my program logic will continuosly loop and try to fetch this document in each iteration .Also I have specified the 
time gap between the successive requests is 3 seconds then during the second iteration my program gives segmentaion fault and it occurs due to the HTHost_setEventTimeout(3000);
call in the code.Could anyone explain me why this could occur?

Thanks
Sandesh

PRIVATE int request_terminater (HTRequest * request, HTResponse * response,
    void * param, int status) 
{
    /*Stop the event loop and quit*/
    HTEventList_stopLoop ();
    return HT_OK;
}

/* ------------------------------------------------------------------------- */
/* xrayhttpget will now accept the uri and length of the uri*/
int xrayhttpget ( char * argv ,int len, int completeURI)
{
 App * app = NULL;
 HTRequest * request = NULL;
 HTAnchor * anchor = NULL;

 /* Need our own trace and print functions */
 HTPrint_setCallback(printer);
 HTTrace_setCallback(tracer);
 char * uri = HTParse(argv, NULL, PARSE_ALL);
 if ((anchor = HTAnchor_findAddress(uri)) == NULL)
  anchor = HTAnchor_findAddress(DEFAULT_HOME);
 HT_FREE(uri);

#if 0
 HTSetTraceMessageMask("sop");
#endif

 /* Initiate libwww */
 libwww_setup();

 /* Create a new app obect */
 app = App_new();

 /* Add our own request terminate handler */
 HTNet_addAfter(request_terminater, NULL, app, HT_ALL, HT_FILTER_LAST);
 /*Set the timeout for request */
 HTHost_setEventTimeout(3000);
 /* Start request */
 request = Request_new(app ,argv ,len, completeURI);
 if(get_document(request, anchor) == YES) {
  /* Go into the event loop... */
  HTEventList_loop(request);
 }
     
 Request_delete(app, request);
 App_delete(app);
 return 0;
}
Received on Wednesday, 8 October 2003 03:18:07 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 23:39:35 UTC