Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internet Protocols Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

B.6 WWW Page Retrieval: Using the HTTP Agent

The example program in this section demonstrates how to fetch a World Wide Web (WWW) page using the HTTP agent class.

HTTP is the native protocol of the WWW. It is a stateless client-server protocol: the client requests a document from the server using its Universal Resource Locator (URL), the server transmits the document to the client, and then the server shuts down the connection.

An HTTP URL has the following format:

where:

<hostname> is the host name (or IP address) of the server;

<port> is the port number for the server, which defaults to 80;

<path> is the path to the document. An empty path returns the root document.

B.6.1 Code and Explanation

Here is a portion of code followed by comments explaining key lines.

//1Reports the HTTP server information to standard output. Note that an HTTP URL is stored in url, which is an instance of the Internet Protocols package's RWURL convenience class. This class encapsulates the parsing and component management of URL information. Here, the host() method of RWURL returns the host portion of the URL.
//2Constructs an RWIHttpAgent object that connects to an HTTP/1.0 compliant server.
//3Executes the get() method to retrieve the indented document, and redeems the RWSocketPortal from the returned RWIOUResult. Note that this function call may block.
//4Builds an input stream from the socket portal.
//5Reads the document's data from the socket portal.

B.6.2 Further Discussion

The RWURL class is provided in the Internet Protocols package as a convenience class. It recognizes some popular URL schemes and parses out their various parts via its methods. See the entry for class RWURL in the Internet Protocols Module Reference Guide for further information.



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.