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.

Yes, I agree that the 1st thread still can do something else once it sends out requests, no matter the server responds instantly or not
And I also agree that one thread is enough for regular cases.
But fundementally, my application has 2 threads, I can't change it since it is related to upper implementation logic of my application
Based on this principle, I have to have 2 threads from my application side to use libwww.
The problem is not how many threads I need to have, the problem is can we have multi-threaded application which uses libwww?

Please kindly take a look at another message posted by me regarding the details I encountered:

Subject: how pipeline works ( Jerry G. Chiuan (Tuesday, 9 September) )

So, is it possible that we can have 2 threads which have "individual" TCP connections for sending requests? ( not share the same one underneath )

If not, can we init 2 libwww for 2 threads? Please refer to my another message posted

can we init 2 libwww? ( Jerry G. Chiuan (Tuesday, 9 September) )
 


I very appreciate your suggestions
- Jerry

> 
> 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 13:12:37 UTC