W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2005

I need some help with libwww

From: Ivan Tarapov <itarapov@telcos.net.ua>
Date: Wed, 30 Nov 2005 20:52:12 +0200
To: "libwww w3c" <www-lib@w3.org>
Message-Id: <20051130185211.A6D6DCCEA6@mail.telcos.net.ua>
Hello,

 

I have been trying to grasp the libwww concepts for several days already,
but they still remain very vague to me. 

There are several questions I'd like to see answers to:

 

1. I have been trying to launch a sample application - the one that counts
number of bytes in the body

 

#define url "http://www.google.com"

 

int main()

{

      HTRequest * request;

 

      HTProfile_newPreemptiveRobot("TestApp", "1.0");

      request = HTRequest_new();

      HTRequest_setOutputFormat(request, WWW_SOURCE);

 

      if (url && *url) {

            HTParentAnchor *
anchor=(HTParentAnchor*)HTAnchor_findAddress(url);

            BOOL status =

                  HTLoadToStream(url,

                  HTContentCounter(&readerStream, request,0x2000),

                  request);

            if (status)

                  printf("Content length found to be %ld bytes\n",

                  HTAnchor_length(anchor));

            else

                  printf("Content length could not be found\n");

      } else

            printf("Bad parameters - please try again\n");

 

      HTRequest_delete(request);               /* Delete the request object
*/

      HTProfile_delete();

return 0;

}

 

The code is executed, however I get an error message in trace output

TRACE: Error....... Add  73     Severity: 1     Parameter: `WinSock reported
error=10093'       Where: `gethostbyname'

 

and, the content length is found to be -1. 

Error 10093 means that WinSock hasn't been initialized. 

Does this mean that the example was wrong? Or it was I who missed something?

 

2. How should I handle errors in libwww? For example, what should I add to
the above mentioned code to handle connection reset? Absence of connection?
Invalid address? Invalid DNS record etc. Is there a single mechanism like
Win32's GetLastError() or there is a separate scenario for each error?

 

3. I'd very much appreciate if someone had written me a simple program that
would issue GET request to a particular server on a particular port with
several headers that are set manually and print a response from server to
the console.

 

 

I hope for your help as I feel like I'm at complete loss with libwww

 

Thank you,

Ivan
Received on Wednesday, 30 November 2005 19:53:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:45 GMT