W3C home > Mailing lists > Public > www-lib@w3.org > April to June 2002

Fw: Newbie - Please help !!!

From: Nitin Duggal <nitin@modena.stpn.soft.net>
Date: Wed, 29 May 2002 16:46:40 +0530
Message-ID: <01e901c20702$508d4600$4380a4a4@Nitin>
To: <www-lib@w3.org>
Cc: <frystyk@w3.org>
Hi Again,

The following is the code snippets from my Java server, which may be useful in understanding my Libwww usage:

Java server (Jetty):
            ServerSocket m_socket = new ServerSocket (1400, 5);
            Socket incoming = m_socket.accept();
            HttpConnection httpCon = new HttpConnection (incoming.getInputStream(), incoming.getOutputStream());

            for (int i=0;;i++)
                // Waiting for request from client
                HttpRequest m_request = httpCon.getRequest();
                DataInputStream in = new DataInputStream (m_request.getInputStream());
                byte arr[] = new byte[1024];
                int len = in.read(arr);
                System.out.println("Received -> " + new String (arr, 0, len));
                // Sending the response to client
                String resp = new String ("i can hear you " + i);
                HttpResponse response = httpCon.getResponse();
                response.setIntField(HttpFields.__ContentLength, (int) resp.getBytes().length);
                Writer writer = response.getOutputStream().getRawWriter();
                DataOutputStream out = new DataOutputStream (response.getOutputStream());
                System.out.println("Sending the data to client..");

The server simply waits for requests from the client and then sends back the response. How do I accomplish this using Libwww. Is the following approach correct:

  status = HTPostAnchor(src, anchor, request);
  if (status == YES)

  printf ("Receiving data from server..\n");
  status = HTLoadAnchor(anchor, request);
  if (status == YES)

The first event loop call hangs and some exception gets thrown on the server-side. I am sure that above code has some problem since my Java Http client does not cause any problem. What should be the correct usage? What sort of connection mode should be set? Anything related to terminate handler? Please help.. Urgent!!


----- Original Message ----- 
From: Nitin Duggal 
To: www-lib@w3.org 
Sent: Wednesday, May 29, 2002 3:09 PM
Subject: Newbie - Please help !!!

Hi All,
I am trying to use Libwww for communicating with HTTP Java server implemented using Jetty (java open-source). I am unable to understand the purpose of Event Loop and when does the function call HTEventList_loop terminates. 
I am posting some text message to the http server and then entering the Event loop, but my application gets stuck. I have also set the required after filter to stop the loop. But it is not getting invoked. However it is working perfectly for GET function calls. What could be the reason for this. 

Please help. Any docs for understanding the APIs or will I have to explore the entire code.

Received on Wednesday, 29 May 2002 07:09:03 UTC

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