First implementation of socket stream classes derived
[sockstream.git] / test / intest.cpp
1 /**************************************************************************
2 **  (c) Copyright 2012, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
6 **      FILE NAME      : intest.cpp
7 **      SYSTEM NAME    : Network and socket classes - test routine
8 **      VERSION NUMBER : 0.1
9 **
10 **  DESCRIPTION      :  Input stream test.
11 **                      Connects to TCP port 1234 and reads a line.
12 **                      Test with: echo "this is a test"|nc -l 1234
13 **
14 **  EXPORTED OBJECTS : 
15 **  LOCAL    OBJECTS : 
16 **  MODULES  USED    :
17 ***************************************************************************
18 **  ADMINISTRATIVE INFORMATION *
19 ********************************
20 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
21 **      CREATION DATE   : Oct 19, 2012
22 **      LAST UPDATE     : Oct 29, 2012
23 **      MODIFICATIONS   : 
24 **************************************************************************/
25
26 #include "sockstream.h"
27
28
29 /*=========================================================================
30 **  NAME           : main
31 **  SYNOPSIS       :
32 **  PARAMETERS     :
33 **  RETURN VALUE   : None
34 **
35 **  DESCRIPTION    : Read lines of text from port 1234 and echo these lines
36 **                   to cout.
37 **
38 **  VARS USED      :
39 **  VARS CHANGED   :
40 **  FUNCTIONS USED :
41 **  SEE ALSO       :
42 **  LAST MODIFIED  : Oct 29, 2012
43 **=========================================================================
44 */
45
46 int main()
47 {
48    IPSocketAddress serveraddress(InternetAddress("127.0.0.1"), Port(1234));
49
50    StreamSocket s;
51
52    s.Connect(serveraddress);
53    isockstream reader(s);
54
55    String buf;
56    while (reader >> buf)
57    {
58       std::cout << buf << "\n";
59    }
60 }
61