work in progress

This commit is contained in:
2022-11-06 23:30:21 +01:00
parent f13900156e
commit 8bdf357e1a
4 changed files with 45 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
#include <arpa/inet.h>
#include <iostream>
#include <unistd.h>
#include <string.h>
void Connection::p_HandleError(){
std::cout << "an error occured during execution" << std::endl;
@@ -45,3 +46,23 @@ Connection::Connection(std::string server_ip, int port){
Connection::~Connection(){
close(fd);
}
bool Connection::send(std::vector<Payload> payloads){
for (Payload& p : payloads) {
::send(fd, p.getData() , p.getSize(), 0);
}
return true;
}
Payload Connection::recv(){
Payload ret;
char temp[100];
memset(temp, 0, 100);
ssize_t size;
while((size = ::recv(fd, temp, sizeof(temp), 0)) > 0){
for(char& in: temp){
ret.push_char(in);
}
}
return ret;
}