From: Arjen Baart Date: Fri, 16 Nov 2012 15:58:59 +0000 (+0100) Subject: Added close() method to stream classes. X-Git-Url: http://www.andromeda.nl/gitweb/?p=sockstream.git;a=commitdiff_plain;h=0e4150c35a9edbf4a250138b846ccf1cc52c1e3d Added close() method to stream classes. --- diff --git a/test/http_get.cpp b/test/http_get.cpp new file mode 100644 index 0000000..19ba1b5 --- /dev/null +++ b/test/http_get.cpp @@ -0,0 +1,71 @@ +/************************************************************************** +** (c) Copyright 2012, Andromeda Technology & Automation +*************************************************************************** +** MODULE INFORMATION * +*********************** +** FILE NAME : http-get.cpp +** SYSTEM NAME : Network and socket classes - test routine +** VERSION NUMBER : 0.1 +** +** DESCRIPTION : Use a Socket object to download a page from an HTTP server. +** +** EXPORTED OBJECTS : +** LOCAL OBJECTS : +** MODULES USED : +*************************************************************************** +** ADMINISTRATIVE INFORMATION * +******************************** +** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl +** CREATION DATE : Mar 02, 2012 +** LAST UPDATE : Mar 05, 2012 +** MODIFICATIONS : +**************************************************************************/ + + +#include "host.h" +#include "service.h" +#include "sockstream.h" + + +/*========================================================================= +** NAME : main +** SYNOPSIS : +** PARAMETERS : +** RETURN VALUE : None +** +** DESCRIPTION : +** +** VARS USED : +** VARS CHANGED : +** FUNCTIONS USED : +** SEE ALSO : +** LAST MODIFIED : Nov 01, 2012 +**========================================================================= +*/ + +int main() +{ + std::cout << "Finding www.andromeda.nl\n"; + Host server(String("www.andromeda.nl")); + std::list iplist = server.FindAddress(); + + Service srv("http"); + std::list portlist = srv.FindAddress(); + + IPSocketAddress serveraddress(iplist.front(), portlist.front()); + StreamSocket s; + + std::cout << "Connection result = " << s.Connect(serveraddress) << "\n"; + sockstream http(s); + + http << "GET / HTTP/1.1\n"; + http << "Host: www.andromeda.nl\n" << std::endl; + + String buf; + while (http >> buf) + { + std::cout << buf << "\n"; + } + +} +