This commit is contained in:
Erik Frojdh
2019-06-05 17:30:21 +02:00
parent 3d6404952a
commit 03f8b389ad
5 changed files with 1347 additions and 2 deletions

35
tests/src/testclient.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "ClientSocket.h"
#include "clara.hpp"
#include <iostream>
#include "container_utils.h"
int main(int argc, char** argv) {
std::cout << "Test client\n";
std::string hostname{"localhost"};
int port = 2345;
auto cli =
clara::Opt(hostname, "hostname")["-hn"]["--hostname"]("Hostname") |
clara::Opt(port, "port")["-p"]["--port"]("Port to send to");
auto result = cli.parse(clara::Args(argc, argv));
if (!result) {
std::cerr << "Error in command line: " << result.errorMessage()
<< std::endl;
exit(1);
}
std::cout << "Sending to: " << hostname << ":" << port << "\n";
auto data = sls::make_unique<char[]>(5000);
for (int64_t i = 0; i!=10; ++i){
std::cout << "Sending: " << i << "\n";
auto socket = sls::ClientSocket("test", hostname, port);
std::cout << "Sent: " << socket.sendData(i) << " bytes\n";
std::cout << "Sent: " << socket.sendData(data.get(), 5000) << " bytes\n";
}
}