This commit is contained in:
Erik Frojdh 2019-06-05 17:45:02 +02:00
parent 6c64bdb04a
commit e46f3f9a2c
2 changed files with 9 additions and 4 deletions

View File

@ -4,6 +4,8 @@
#include <iostream> #include <iostream>
#include "container_utils.h" #include "container_utils.h"
constexpr size_t MB = 1048576;
int main(int argc, char** argv) { int main(int argc, char** argv) {
std::cout << "Test client\n"; std::cout << "Test client\n";
std::string hostname{"localhost"}; std::string hostname{"localhost"};
@ -20,13 +22,14 @@ int main(int argc, char** argv) {
} }
std::cout << "Sending to: " << hostname << ":" << port << "\n"; std::cout << "Sending to: " << hostname << ":" << port << "\n";
auto data = sls::make_unique<char[]>(5000); constexpr size_t size = 1*MB;
auto data = sls::make_unique<char[]>(size);
for (int64_t i = 0; i!=10; ++i){ for (int64_t i = 0; i!=10; ++i){
std::cout << "Sending: " << i << "\n"; std::cout << "Sending: " << i << "\n";
auto socket = sls::ClientSocket("test", hostname, port); auto socket = sls::ClientSocket("test", hostname, port);
std::cout << "Sent: " << socket.sendData(i) << " bytes\n"; std::cout << "Sent: " << socket.sendData(i) << " bytes\n";
std::cout << "Sent: " << socket.sendData(data.get(), 5000) << " bytes\n"; std::cout << "Sent: " << socket.sendData(data.get(), size) << " bytes\n";
} }

View File

@ -4,6 +4,8 @@
#include <iostream> #include <iostream>
#include "container_utils.h" #include "container_utils.h"
constexpr size_t MB = 1048576;
int main(int argc, char **argv) { int main(int argc, char **argv) {
std::cout << "Test server\n"; std::cout << "Test server\n";
int port = 2345; int port = 2345;
@ -18,14 +20,14 @@ int main(int argc, char **argv) {
std::cout << "Listening to port: " << port << "\n"; std::cout << "Listening to port: " << port << "\n";
auto server = sls::ServerSocket(port); auto server = sls::ServerSocket(port);
auto data = sls::make_unique<char[]>(5000); auto data = sls::make_unique<char[]>(1*MB);
while (true) { while (true) {
try { try {
auto socket = server.accept(); auto socket = server.accept();
auto val = socket.receive<long>(); auto val = socket.receive<long>();
std::cout << "Value: " << val << "\n"; std::cout << "Value: " << val << "\n";
std::cout << "Read: " << socket.receiveData(data.get(), 5000) << " bytes"; std::cout << "Read: " << socket.receiveData(data.get(), 1*MB) << " bytes";
} catch (const sls::RuntimeError &e) { } catch (const sls::RuntimeError &e) {
} }