-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
48 lines (39 loc) · 917 Bytes
/
Main.cpp
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
/*
* Main.cpp
*
* Created on: 10.12.2018
* Author: Denis Lugowski
*/
#include <iostream>
#include "PicoTLSTest.h"
int main(int argc, char **argv)
{
PicoTLSTest* tls = nullptr;
char isServer;
std::cout << "Does host acts as a server (y/n)?";
std::cin >> isServer;
if (isServer == 'y') {
// Server
tls = new PicoTLSTest();
tls->createServerSocket(8000);
tls->initPicoTLS();
tls->waitForIncomingConnection();
while (1) {
char* msg = tls->readFromSocket();
printf("Message: %s\n", msg);
delete (msg);
}
}
else {
// Client
tls = new PicoTLSTest();
tls->createClientSocket();
tls->initPicoTLS();
tls->connectToServer(8000);
while (1) {
tls->writeToSocket();
}
}
tls->cleanupPicoTLS();
tls->closeSocket();
}