forked from embeddedmz/socket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
31 lines (22 loc) · 883 Bytes
/
test.cpp
File metadata and controls
31 lines (22 loc) · 883 Bytes
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
#include <iostream> //cout
#include <memory>
#include <sstream>
#include "TCPClient.h"
#include "TCPSSLClient.h"
#define PRINT_LOG [](const std::string& strLogMsg) { std::cout << strLogMsg << std::endl; }
using namespace std;
int main(){
unique_ptr<CTCPSSLClient> m_pSSLTCPClient;
m_pSSLTCPClient.reset(new CTCPSSLClient(PRINT_LOG));
//m_pSSLTCPClient->SetSSLKeyFile(SSL_KEY_FILE); // not mandatory
m_pSSLTCPClient->SetSSLCerthAuth("/home/pi/ca_cert.pem");///ca_cert.pem"); // not mandatory
bool bRet = m_pSSLTCPClient->Connect("192.168.10.90", "8000");
stringstream ss;
ss << "GET /rest/throttling HTTP/1.1 \r\n\r\n";
bRet = m_pSSLTCPClient->Send(ss.str());
cout << "Sent message( " << bRet <<" ): " << ss.str() << endl;
char buffer[15];
cout << "starting read"<< endl;
int res_size = m_pSSLTCPClient->Receive(buffer, 9);
cout << buffer << endl;
}