blob: 9d30e5f301ef17f6694aa57df40dda30d031009c [file] [log] [blame]
Alexandre Lisionddd731e2014-01-31 11:50:08 -05001// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
2//
3// This file is part of GNU uCommon C++.
4//
5// GNU uCommon C++ is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published
7// by the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GNU uCommon C++ is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17
18#if defined(OLD_STDCPP) || defined(NEW_STDCPP)
19#ifndef DEBUG
20#define DEBUG
21#endif
22
23#include <ucommon/ucommon.h>
24
25#include <stdio.h>
26
27using namespace UCOMMON_NAMESPACE;
28using namespace std;
29
30class ThreadOut: public JoinableThread
31{
32public:
33 ThreadOut() : JoinableThread() {};
34
35 void run() {
36 Socket::address localhost("127.0.0.1", 9000);
37 tcpstream tcp(localhost);
38 tcp << "pippo" << endl << ends;
39 tcp.close();
40 }
41};
42
43int main(int argc, char *argv[])
44{
45 ThreadOut thread;
46
47 char line[200];
48 TCPServer sock("127.0.0.1", "9000");
49 thread.start();
50 if (sock.wait(1000)){
51 tcpstream tcp(&sock);
52 tcp.getline(line, 200);
53 assert(!strcmp(line, "pippo"));
54 tcp.close();
55 return 0;
56 }
57 assert(0);
58 return 0;
59}
60#else
61
62int main(int argc, char **argv)
63{
64 return 0;
65}
66
67#endif