W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2003

Re: multi-threads using libwww

From: Richard Atterer <richard@list03.atterer.net>
Date: Wed, 10 Sep 2003 10:39:37 +0200
To: www-lib@w3.org
Message-ID: <20030910083937.GC906@nenya.lan>

On Tue, Sep 09, 2003 at 09:35:07AM -0700, Jerry G. Chiuan wrote:
> The application needs to send 2 kinds of requests, one would be held by
> server and the server responds either there is something which needs to
> be returned before timeout -or- timeout occurs ( return nothing ). Based
> on this, the thread needs to wait for the reponse as I mention above,
> then can keep going down. But it would delay the process for "another"
> kind of requests.

No - your basic wrong assumption is that once your application has started 
waiting for the response, nothing else can happen. But with the system 
calls I mentioned earlier, this doesn't need to be the case.

In your case, the code using libwww would do roughly the following:

 - Register a filter with HTAlert_add(). This function will later get
   called whenever something "interesting" happens to any HTRequest, for
   example a timeout or a successful retrieval.
 
 - Maybe also register a callback with HTNet_addAfter(), if you need its 
   information.
 
 - Create and set up one or several HTRequests, run them with HTLoad()

 - Call the event loop, maybe with HTEventList_newLoop().
 
From now on, the event loop will be executed until you call exit()
somewhere. You should be able to start additional requests from the
callbacks.

Cheers,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/|  http://atterer.net  |  0x888354F7
   '` 
Received on Wednesday, 10 September 2003 04:44:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:43 GMT