Added close() method to stream classes.
authorArjen Baart <arjen@andromeda.nl>
Fri, 16 Nov 2012 15:58:59 +0000 (16:58 +0100)
committerArjen Baart <arjen@andromeda.nl>
Fri, 16 Nov 2012 15:58:59 +0000 (16:58 +0100)
test/http_get.cpp [new file with mode: 0644]

diff --git a/test/http_get.cpp b/test/http_get.cpp
new file mode 100644 (file)
index 0000000..19ba1b5
--- /dev/null
@@ -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<InternetAddress> iplist = server.FindAddress();
+
+   Service srv("http");
+   std::list<Port> 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";
+   }
+
+}
+