forked from embeddedmz/socket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCPSSLClient.h
More file actions
56 lines (45 loc) · 1.47 KB
/
TCPSSLClient.h
File metadata and controls
56 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* @file TCPSSLClient.h
* @brief wrapper for TCP SSL client
*
* @author Mohamed Amine Mzoughi <[email protected]>
* @date 2017-02-16
*/
#ifdef OPENSSL
#ifndef INCLUDE_TCPSSLCLIENT_H_
#define INCLUDE_TCPSSLCLIENT_H_
#include "SecureSocket.h"
#include "TCPClient.h"
class CTCPSSLClient : public ASecureSocket
{
public:
explicit CTCPSSLClient(const LogFnCallback& oLogger,
const OpenSSLProtocol& eSSLVersion = OpenSSLProtocol::TLS,
const SettingsFlag eSettings = ALL_FLAGS);
~CTCPSSLClient() override;
CTCPSSLClient(const CTCPSSLClient&) = delete;
CTCPSSLClient& operator=(const CTCPSSLClient&) = delete;
/* connect to a TCP SSL server */
bool Connect(const std::string& strServer, const std::string& strPort);
/* disconnect from the SSL TCP server */
void Disconnect();
int Receive(char* pData, size_t uSize, bool bReadFully = true) const;
/* send data to a TCP SSL server */
int Send(const char* pData, size_t uSize) const;
int Send(const std::string& strData) const;
int Send(const std::vector<char>& Data) const;
bool SetRcvTimeout(unsigned int timeout);
bool SetSndTimeout(unsigned int timeout);
#ifndef _WIN32
bool SetRcvTimeout(struct timeval timeout);
bool SetSndTimeout(struct timeval timeout);
#endif
/* receive data from a TCP SSL server */
bool HasPending();
int PendingBytes();
protected:
CTCPClient m_TCPClient;
SSLSocket m_SSLConnectSocket;
};
#endif
#endif