TUIO C++ Developer API
TcpReceiver.h
1 /*
2  TUIO C++ Library
3  Copyright (c) 2005-2017 Martin Kaltenbrunner <martin@tuio.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 3.0 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library.
17 */
18 
19 #ifndef INCLUDED_TCPRECEIVER_H
20 #define INCLUDED_TCPRECEIVER_H
21 
22 #include "OscReceiver.h"
23 #define MAX_TCP_SIZE 65536
24 
25 #ifdef WIN32
26 #include <winsock.h>
27 #include <io.h>
28 typedef int socklen_t;
29 #else
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 #include <netinet/in.h>
33 #include <netdb.h>
34 #include <arpa/inet.h>
35 #include <unistd.h>
36 #endif
37 
38 namespace TUIO {
39 
46  class LIBDECL TcpReceiver: public OscReceiver {
47 
48  public:
49 
55  TcpReceiver (int port=3333);
56 
63  TcpReceiver (const char *host, int port);
64 
68  virtual ~TcpReceiver();
69 
75  void connect(bool lock=false);
76 
80  void disconnect();
81 
82 #ifndef WIN32
83  int tcp_socket;
84  std::list<int> tcp_client_list;
85 #else
86  SOCKET tcp_socket;
87  std::list<SOCKET> tcp_client_list;
88 #endif
89 
90  private:
91 
92 #ifndef WIN32
93  pthread_t server_thread;
94 #else
95  HANDLE server_thread;
96  DWORD ServerThreadId;
97 #endif
98 
99  bool locked;
100  };
101 };
102 #endif /* INCLUDED_TcpReceiver_H */
Definition: FlashSender.h:166
Definition: TcpReceiver.h:46
Definition: OscReceiver.h:40