Re: multi-threads using libwww

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 UTC