TUIO C++ Developer API
TcpSender.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_TCPSENDER_H
20 #define INCLUDED_TCPSENDER_H
21 
22 #include "OscSender.h"
23 
24 #ifdef WIN32
25 #include <winsock.h>
26 #include <io.h>
27 typedef int socklen_t;
28 #else
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <netdb.h>
33 #include <arpa/inet.h>
34 #include <unistd.h>
35 #endif
36 
37 #include <list>
38 #define MAX_TCP_SIZE 65536
39 
40 namespace TUIO {
41 
48  class LIBDECL TcpSender : public OscSender {
49 
50  public:
51 
55  TcpSender();
56 
63  TcpSender(const char *host, int port);
64 
70  TcpSender(int port);
71 
75  virtual ~TcpSender();
76 
84  bool sendOscPacket (osc::OutboundPacketStream *bundle);
85 
91  bool isConnected ();
92 
98  virtual void newClient( int tcp_client );
99 
100  int port_no;
101 
102 #ifdef WIN32
103  SOCKET tcp_socket;
104  std::list<SOCKET> tcp_client_list;
105 #else
106  int tcp_socket;
107  std::list<int> tcp_client_list;
108 #endif
109  bool connected;
110  const char* tuio_type() { return "TUIO/TCP"; }
111 
112  protected:
113  char data_size[4];
114  char data_buffer[MAX_TCP_SIZE+4];
115 
116 
117 #ifdef WIN32
118  HANDLE server_thread;
119  DWORD ServerThreadId;
120 #else
121  pthread_t server_thread;
122 #endif
123 
124  };
125 }
126 #endif /* INCLUDED_TCPSENDER_H */
Definition: FlashSender.h:166
Definition: OscSender.h:37
Definition: TcpSender.h:48