ISTcpClient.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 __ISTCPCLIENT__H__
14 #define __ISTCPCLIENT__H__
15 
16 #include <string>
17 #include <inttypes.h>
18 
19 #include "ISStream.h"
20 
21 #define IS_SOCKET_DEFAULT_TIMEOUT_MS 5000
22 
23 using namespace std;
24 
25 class cISTcpClient : public cISStream
26 {
27 public:
31  cISTcpClient();
32 
36  virtual ~cISTcpClient();
37 
45  int Open(const string& host, int port, int timeoutMilliseconds = IS_SOCKET_DEFAULT_TIMEOUT_MS);
46 
51  int Close() OVERRIDE;
52 
59  int Read(void* data, int dataLength) OVERRIDE;
60 
67  int Write(const void* data, int dataLength) OVERRIDE;
68 
76  void HttpGet(const string& subUrl, const string& userAgent, const string& userName, const string& password);
77 
82  bool IsOpen() { return m_socket != 0; }
83 
88  bool GetBlocking() { return m_blocking; }
89 
94  int SetBlocking(bool blocking);
95 
96 private:
97  cISTcpClient(const cISTcpClient& copy); // Disable copy constructor
98 
99  socket_t m_socket;
100  string m_host;
101  int m_port;
103 };
104 
109 
114 
121 int ISSocketCanWrite(socket_t socket, int timeoutMilliseconds = IS_SOCKET_DEFAULT_TIMEOUT_MS);
122 
129 int ISSocketCanRead(socket_t socket, int timeoutMilliseconds = IS_SOCKET_DEFAULT_TIMEOUT_MS);
130 
138 int ISSocketWrite(socket_t socket, const uint8_t* data, int dataLength);
139 
147 int ISSocketRead(socket_t socket, uint8_t* data, int dataLength);
148 
155 int ISSocketSetBlocking(socket_t socket, bool blocking);
156 
163 int ISSocketSetReadTimeout(socket_t socket, int timeoutMilliseconds);
164 
170 int ISSocketClose(socket_t& socket);
171 
172 #endif // __ISTCPCLIENT__H__
socket_t m_socket
Definition: ISTcpClient.h:99
NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
Definition: socket.c:477
int ISSocketCanWrite(socket_t socket, int timeoutMilliseconds=IS_SOCKET_DEFAULT_TIMEOUT_MS)
Definition: ISTcpClient.cpp:76
Write
#define OVERRIDE
Definition: ISConstants.h:423
int ISSocketSetReadTimeout(socket_t socket, int timeoutMilliseconds)
int ISSocketRead(socket_t socket, uint8_t *data, int dataLength)
void ISSocketFrameworkShutdown()
Definition: ISTcpClient.cpp:57
int ISSocketCanRead(socket_t socket, int timeoutMilliseconds=IS_SOCKET_DEFAULT_TIMEOUT_MS)
Definition: ISTcpClient.cpp:86
int ISSocketClose(socket_t &socket)
int ISSocketSetBlocking(socket_t socket, bool blocking)
int ISSocketWrite(socket_t socket, const uint8_t *data, int dataLength)
Definition: ISTcpClient.cpp:96
USBInterfaceDescriptor data
#define IS_SOCKET_DEFAULT_TIMEOUT_MS
Definition: ISTcpClient.h:21
string m_host
Definition: ISTcpClient.h:100
Read
bool GetBlocking()
Definition: ISTcpClient.h:88
void ISSocketFrameworkInitialize()
Definition: ISTcpClient.cpp:40
bool IsOpen()
Definition: ISTcpClient.h:82


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