Socket Factory has only one function which works for server and client code, and can do tls for both

This commit is contained in:
Benjamin Sergeant
2019-09-30 22:06:46 -07:00
parent 313949f087
commit afed387bcf
18 changed files with 39 additions and 48 deletions

View File

@ -61,7 +61,8 @@ TEST_CASE("socket", "[socket]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
SocketTLSOptions tlsOptions;
std::shared_ptr<Socket> socket = createSocket(tls, -1, errMsg, tlsOptions);
std::string host("127.0.0.1");
std::stringstream ss;
@ -84,7 +85,7 @@ TEST_CASE("socket", "[socket]")
bool tls = true;
SocketTLSOptions tlsOptions;
tlsOptions.caFile = "cacert.pem";
std::shared_ptr<Socket> socket = createSocket(tls, errMsg, tlsOptions);
std::shared_ptr<Socket> socket = createSocket(tls, -1, errMsg, tlsOptions);
std::string host("www.google.com");
int port = 443;
std::string request("GET / HTTP/1.1\r\n\r\n");

View File

@ -92,7 +92,8 @@ TEST_CASE("Websocket_server", "[websocket_server]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
SocketTLSOptions tlsOptions;
std::shared_ptr<Socket> socket = createSocket(tls, -1, errMsg, tlsOptions);
std::string host("127.0.0.1");
auto isCancellationRequested = []() -> bool { return false; };
bool success = socket->connect(host, port, errMsg, isCancellationRequested);
@ -125,7 +126,8 @@ TEST_CASE("Websocket_server", "[websocket_server]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
SocketTLSOptions tlsOptions;
std::shared_ptr<Socket> socket = createSocket(tls, -1, errMsg, tlsOptions);
std::string host("127.0.0.1");
auto isCancellationRequested = []() -> bool { return false; };
bool success = socket->connect(host, port, errMsg, isCancellationRequested);
@ -161,7 +163,8 @@ TEST_CASE("Websocket_server", "[websocket_server]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
SocketTLSOptions tlsOptions;
std::shared_ptr<Socket> socket = createSocket(tls, -1, errMsg, tlsOptions);
std::string host("127.0.0.1");
auto isCancellationRequested = []() -> bool { return false; };
bool success = socket->connect(host, port, errMsg, isCancellationRequested);