W3C libwww

Libwww Ready to go Examples

This is the list of small examples using the very basic features of the Library. If you have not already compiled the library then please read the Installation guide before you continue. If you want more details of how to use the Library then please read the User's Guide.

In the example we assume that the compiler knows where to look for the Library include file WWWLib.h and also knows where to find the binary library, often called libwww.a on Unix platforms and libwww.lib on Windows. Again, the result might depend on the setup of the dynamic modules, but if no dynamic modules are enabled then the example will generate an executable file. If you are in doubt about how to set your compiler then you can often get some good ideas by looking into the Line Mode Browser, the Command Line Tool, and the Robot which all run on both Unix and Win32.  If you are using the GNU autoconf configure script then the examples are built as part of the overall package. On other platforms, you must provide the make file on your own.

Some platforms require a socket library when building network applications. This is for example the case when building on Macintosh or Windows machines. The Library uses the GUSI socket library on the Macintosh and the WinSock library on windows platforms. Please check the documentation on these libraries for how to install them and also if there are any specific requirements on your platform when building network applications.

Start and Stop the Library
This is a dummy program that just initializes as terminates the Library
Default Initialization of libwww
This example shows how to set up all the default handlers, parsers, converters, etc. using the WWWInit interface.
Specialized Initialization of libwww
This example show how to register a protocol module and a stream converter
Issue a HEAD request
This small example sets up a request and performs a HEAD method on the URL given on the command line
Load a Document into Memory
A simple example of how you can create a memory buffer containing the contents of the URL and all the protocol headers.
Load a Document into Memory
This program shows how to load a URL into memory without getting the header information.
Load a URL and counnt the number of bytes in the body
This is an example of how you can add streams and then get the desired result. The example shows how to add a content length counter stream and get the result back.
Load a URL to local File
We here show how to fetch a URL using HTTP and to save it to local file. You must specify a local file name on the command line. There are two versions of this program: The preemptive version with no event loop and the non-preemptive version for integration with Windows' event and other event loops.

You can also have a look at the more complete example applications which are capable of doing more interesting things. If you have any example code that you would like to share with us then please send us a mail so that we can add it to this page.


Henrik Frystyk Nielsen,
@(#) $Id: Overview.html,v 1.13 1998/05/07 15:08:07 frystyk Exp $