VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtTcpServer.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2017 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #ifndef DtIGITCPServer_H_
11 #define DtIGITCPServer_H_
12 
13 #include <vrvCore/vrvCore.h>
14 
15 #include <list>
16 #include <string>
17 
18 #ifdef _WIN32
19 struct fd_set;
20 #else
21 #include <sys/types.h>
22 #endif
23 
24 
25 namespace makVrv
26 {
27  class DtDe;
28  class DtMessageDispatcher;
29  class DtTcpMessageClient;
30 
34  {
35  public:
36 
37  typedef std::list<DtTcpMessageClient*> ClientList;
38 
39  static const std::string theServerHandshake;
40  static const std::string theClientHandshake;
41 
43  DtTcpServer(DtDe& de,int port);
44 
46  ~DtTcpServer();
47 
49  bool isListening() const;
50 
52  void startListening();
53 
55  void stopListening();
56 
58  int numberOfConnections();
59 
61  void cleanupDisconnectedClients();
62 
64  void checkForMessages();
65 
69  void addClient(DtTcpMessageClient*);
70 
72  const ClientList& clients() const;
73 
75  void deleteClient(DtTcpMessageClient* client, bool lostConnection=false);
76 
78  DtTcpMessageClient* findClient(const std::string& name);
79 
81  void deleteClients();
82 
84  static void setBlocking(int fd, bool blocking);
85 
86 #ifdef USE_IN_MEMORY_PROFILER
87  void startProfiler();
88 #endif
89 
90  protected:
91 
93  void handleNewConnections();
94 
96  void buildSocketList();
97 
99  void processReads();
100 
101 
103  int mySocket;
105  int myPort;
106  fd_set* myReceiveSet;
107 
110  };
111 }
112 
113 #endif

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)