ACT-CV - Machine Vision for Cognitive Modeling
tcpserver.h
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; coding: iso-8859-1; -*-
2 
3 /*
4 ACT-CV - Machine Vision for Cognitive Modeling
5 Copyright (c) 2008 Marc Halbruegge
6 
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 
22 
27 #ifndef __TCPSERVER_H
28 #define __TCPSERVER_H
29 
30 #ifdef _WINDOWS
31 #include <winsock.h>
32 #else
33 #define SOCKET int
34 #endif
35 
36 #include <stdexcept>
37 
38 #include <garbagecoll.h>
39 #include <GCString.h>
40 #include <Threads/Mutex.h>
42 
43 #include <config.h>
44 
45 #ifndef _WINDOWS
46 # define HANDLE int
47 #endif
48 
50 class ServerError : public std::runtime_error {
51 public:
52  ServerError(const char *s) : std::runtime_error(s) {
53  }
54 };
55 
64 class ActCvServer {
65  friend struct ActCvServerAutoStop;
66 
68  ActCvServer();
69  ~ActCvServer();
70 
72  bool running;
73 
74  static void ThreadFun(void*p);
76 
85 
86 protected:
87  void SetupServerSocket(int portNum);
89  void WriteData(SOCKET s);
90 
91 public:
92 
95  if (singleInstance==nullptr) {
97  }
98  return singleInstance;
99  }
100 
102  void SetData(const char *s);
103 
106 };
107 
108 
109 #endif


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)