W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2003

Re: libwww threads and clients

From: Richard Atterer <richard@list03.atterer.net>
Date: Mon, 24 Feb 2003 20:26:09 +0100
To: jd sw <jdsw2002@yahoo.com>
Cc: www-lib@w3.org
Message-ID: <20030224192609.GA24188@nenya.lan>

On Sun, Feb 23, 2003 at 12:18:29AM -0800, jd sw wrote:
> A. Can libwww be used in a multithreaded program ? Which portions of the
> library are thread safe ? 

libwww is not thread safe - if your application is multithreaded, you'll 
have to take care that only one thread accesses it.

However, libwww allows multiple simultaneous downloads - its event loop can 
call select() to wait for something to happen with any one out of several 
sockets. This event loop model happens to fit well into the event loop 
model of graphical toolkits like GTK+. For GTK+, there's even "glibwww", 
which integrates the libwww event loop into the glib event loop.

> B. How does one go about simulating multiple http clients (browser like)
> in the same process where cookies, cache etc are kept separate each
> "client". 

Keeping track of the different clients' state would be your application's
job - with libwww, you can start requests and attach extra headers
(cookies, user-agent etc.)

I think libwww's cache does not allow such a separation (I could be wrong),
but you can just not use the cache.

BTW, the biggest problem of libwww for new users is probably that it seems
so bloated and behaves in strange ways sometimes. For this reason, 
expect to be forced to have a look at its sources from time to time.

If you want a thread safe library which is similar to libwww and much 
cleaner, have a look at libcurl. However, libcurl does not support HTTP 



  __   _
  |_) /|  Richard Atterer     |  CS student at the Technische  |  GnuPG key:
  | \/¯|  http://atterer.net  |  Universität München, Germany  |  0x888354F7
  ¯ '` ¯
Received on Monday, 24 February 2003 15:14:25 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:55 UTC