Re: threading

At 13:59 17/03/1999 -0800, Andrew Wong wrote:

>I'm trying to write a simple testing tool, which will simultaneously fetch 
>pages from different URLs, using libwww. 

libwww doesn't support pthreads yet - there have been several discussions
on the www-lib maling list for handling this, so maybe you should ask there.

However, libwww can easily handle multiple simultaneous requests using it's
own thread model. This is essentially what the libwww eventloop is all
about - you can see a couple of examples at

	http://www.w3.org/Library/Examples/#event

>Therefore I tried to modify showlinks.c. I moved all the original code in 
>main() to a procedure, showlinks(). Inside main(), pthread_create() is
>called to run showlinks() and then it waits for the thread to terminate by
>calling pthread_join(). 

The showlink example already uses the eventloop - it is just currently set
to only do one download. The eventloop.c sample can do as many downloads
you like. You can also see the sample timy browser to see another example:

	http://www.w3.org/Library/Examples/#HTML

>However, this simple modification doesn't seem to work and I don't know why.
>I traced the code in GDB and it failed at HTTCP.c:280 connect() Does this
>have anything to do with I/O multiplexing in libwww? It's very helpful if
>you could give me some advice. I am using verison 5.26. Thanks alot for your
>time!!!

Could be that you are using non-blocking sockets without going into the
eventloop. See the sample apps for how to do this.

Henrik
--
Henrik Frystyk Nielsen,
World Wide Web Consortium
http://www.w3.org/People/Frystyk

Received on Wednesday, 17 March 1999 20:13:17 UTC