First implementation of socket stream classes derived
[sockstream.git] / test / outtest.cpp
diff --git a/test/outtest.cpp b/test/outtest.cpp
new file mode 100644 (file)
index 0000000..114c3e3
--- /dev/null
@@ -0,0 +1,61 @@
+/**************************************************************************
+**  (c) Copyright 2012, Andromeda Technology & Automation
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+**      FILE NAME      : outtest.cpp
+**      SYSTEM NAME    : Network and socket classes - test routine
+**      VERSION NUMBER : 0.1
+**
+**  DESCRIPTION      :  Output stream test.
+**                      Connects to TCP port 1234 and writes a line.
+**                      Test with: nc -l 1234
+**
+**  EXPORTED OBJECTS : 
+**  LOCAL    OBJECTS : 
+**  MODULES  USED    :
+***************************************************************************
+**  ADMINISTRATIVE INFORMATION *
+********************************
+**      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+**      CREATION DATE   : Oct 19, 2012
+**      LAST UPDATE     : Oct 30, 2012
+**      MODIFICATIONS   : 
+**************************************************************************/
+
+#include "sockstream.h"
+
+
+/*=========================================================================
+**  NAME           : main
+**  SYNOPSIS       :
+**  PARAMETERS     :
+**  RETURN VALUE   : None
+**
+**  DESCRIPTION    : Read lines of text from port 1234 and echo these lines
+**                   to cout.
+**
+**  VARS USED      :
+**  VARS CHANGED   :
+**  FUNCTIONS USED :
+**  SEE ALSO       :
+**  LAST MODIFIED  : Oct 29, 2012
+**=========================================================================
+*/
+
+int main()
+{
+   IPSocketAddress serveraddress(InternetAddress("127.0.0.1"), Port(1234));
+
+   StreamSocket s;
+
+   s.Connect(serveraddress);
+   osockstream writer(s);
+
+   String buf;
+   while (std::cin >> buf)
+   {
+      writer << buf << std::endl;
+   }
+}
+