ISTcpServer.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2021 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef _ISTCPSERVER__H__
14 #define _ISTCPSERVER__H__
15 
16 #include <string>
17 #include <inttypes.h>
18 #include <vector>
19 
20 using namespace std;
21 
22 #include "ISTcpClient.h"
23 
24 class cISTcpServer;
25 
27 {
28 protected:
36  virtual void OnClientDataReceived(cISTcpServer* server, socket_t socket, uint8_t* data, int dataLength)
37  {
38  (void)server;
39  (void)socket;
40  (void)data;
41  (void)dataLength;
42  }
43 
48  virtual void OnClientConnecting(cISTcpServer* server)
49  {
50  (void)server;
51  }
52 
58  virtual void OnClientConnected(cISTcpServer* server, socket_t socket)
59  {
60  (void)server;
61  (void)socket;
62  }
63 
68  virtual void OnClientConnectFailed(cISTcpServer* server)
69  {
70  (void)server;
71  }
72 
78  virtual void OnClientDisconnected(cISTcpServer* server, socket_t socket)
79  {
80  (void)server;
81  (void)socket;
82  }
83 
84  friend class cISTcpServer;
85 };
86 
87 class cISTcpServer : public cISStream
88 {
89 public:
94 
98  virtual ~cISTcpServer();
99 
106  int Open(const string& ipAddress, int port);
107 
112  int Close();
113 
117  void Update();
118 
125  int Write(const uint8_t* data, int dataLength);
126 
131  bool IsOpen() { return m_socket != 0; }
132 
133 private:
134  cISTcpServer(const cISTcpServer& copy); // Disable copy constructor
135 
136  socket_t m_socket;
137  vector<socket_t> m_clients;
138  string m_ipAddress;
139  int32_t m_port;
141 };
142 
143 #endif
virtual void OnClientConnecting(cISTcpServer *server)
Definition: ISTcpServer.h:48
NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
Definition: socket.c:477
Write
bool IsOpen()
Definition: ISTcpServer.h:131
#define NULL
Definition: nm_bsp.h:52
virtual void OnClientConnected(cISTcpServer *server, socket_t socket)
Definition: ISTcpServer.h:58
virtual void OnClientConnectFailed(cISTcpServer *server)
Definition: ISTcpServer.h:68
USBInterfaceDescriptor data
int32_t m_port
Definition: ISTcpServer.h:139
socket_t m_socket
Definition: ISTcpServer.h:136
virtual void OnClientDataReceived(cISTcpServer *server, socket_t socket, uint8_t *data, int dataLength)
Definition: ISTcpServer.h:36
iISTcpServerDelegate * m_delegate
Definition: ISTcpServer.h:140
vector< socket_t > m_clients
Definition: ISTcpServer.h:137
virtual void OnClientDisconnected(cISTcpServer *server, socket_t socket)
Definition: ISTcpServer.h:78
string m_ipAddress
Definition: ISTcpServer.h:138


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57