C++ World

C++ Resources, Tips,
Documentation, Examples,
HOWTO's, FAQ's, Tools
Libraries, Frameworks, IDE's

 
© 2005,2009 C++ World - All rights reserved - webdesign.arttina
C++, Sockets, SysProg, Libraries, Examples, Tools, Compilers, IDE, STL, XML
Google
FAQ Sockets Socket Library Software Engineering Sysprog Examples Books
 
Home
C++
The C Language
STL
BOOST
GNU
GNU C Compiler
GNU Debugger
GNU Profiler
HP C++ Compiler
DDD
Eclipse
Curses
XML
X11
KDevelop
MS Visual Studio
Tutorials

/* ****************************************************************
   ****************************************************************
   * Com++ Lite (c) 2009 C++ World
   * http://www.cplusplusworld.com/ mailto:compp@cplusplusworld.com
   ****************************************************************
   ****************************************************************
*/

// *************************************************
// File: ExampleHTTPClient.cpp
// Author: franzbrandel@cplusplusworld.com
// (c) 2009 C++ World 
// http://www.cplusplusworld.com/
// Please read the ComPP-Lite Users Guide
// for further explanation.
// *************************************************

#include <stdlib.h>
#include "ComPlusPlus"

int main ( int argc, char *argv [] ) {

 try {
    std::string host= "127.0.0.1" , doc="/index.html" ;	
	
	if ( argc != 3 ) {
	  if ( argc == 2 ){
		try {
			compp::HTTPClnt clnt;
			std::string RetStr;
	
			clnt.Get(argv[1], RetStr); 
			std::cout << "Retrieved String:" << RetStr << "\n" ;
		} catch ( syspp::ComException e ) {
	   		std::cout << " Error :" << e.what() << "\n";	
		}	
		exit( 0);
	  }	
	  std::cout << "Usage: " << argv[0] << "Host: port\n";
	} else {
	  host = argv[1];
	  doc = argv[2];	
	}
	try {
	 compp::HTTPClnt clnt;
	 compp::ByteStream Stream;
	 clnt.Get("www.cplusplusworld.com", 80 , "/index.html", Stream);
	 std::string Out;
         Stream.Get ( Out );
	 std::cout << "Retrieved length:" << Stream.GetLen() << "\n" ;
	 std::cout << "Retrieved :" << Out << "\n" ;
	 exit(0);
	} catch ( syspp::ComException e ) {
	   std::cout << " Error :" << e.what() << "\n";	
	}
  } catch ( syspp::ComException e ) {
     std::cout << " Error :" << e.what() << "\n";	
  }
 return 0;	
}


syntax highlighted by Code2HTML, v. 0.9.1


Franz Brandel Contact Legal Statement Sitemap C++ World