This commit is contained in:
Debucquoy Anthony 2022-11-09 17:49:55 +01:00
parent 15bb2e874c
commit e0423f9bfc
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
4 changed files with 21 additions and 5 deletions

View File

@ -19,7 +19,7 @@ private:
recv = 20, recv = 20,
send send
}error; }error = ErrorTypes::none;
void p_HandleError(); void p_HandleError();

View File

@ -15,3 +15,9 @@ void Payload::setData(std::vector<unsigned char> m_data){
size_t Payload::getSize(){ size_t Payload::getSize(){
return Data.size(); return Data.size();
} }
Payload::Payload(){ }
Payload::Payload(std::vector<unsigned char> m_data)
: Data(m_data){}

View File

@ -15,6 +15,9 @@ public:
void setData(std::vector<unsigned char>); void setData(std::vector<unsigned char>);
void push_char(unsigned char); void push_char(unsigned char);
Payload();
Payload(std::vector<unsigned char>);
}; };
#endif /* PAYLOAD_H */ #endif /* PAYLOAD_H */

View File

@ -1,5 +1,6 @@
#include "Connection.h" #include "Connection.h"
#include "Payload.h" #include "Payload.h"
#include <thread>
#include <iostream> #include <iostream>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -10,13 +11,19 @@ int main(int argc, char *argv[])
}else{ }else{
c = new Connection(argv[1], atoi(argv[2])); c = new Connection(argv[1], atoi(argv[2]));
} }
Payload p; if(c->status() != 0){
p.push_char(0xFE); return 1;
p.push_char(0x01); }
p.push_char(0xFA); std::vector<unsigned char> p_data{0xFE, 0x01, 0xFA, 0x00, 0x08, 0x00, 0x4D, 0x00, 0x43, 0x00, 0x7C, 0x00, 0x50, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x48, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x74};
Payload p(p_data);
c->send(p, true); c->send(p, true);
Payload response = c->recv(); Payload response = c->recv();
std::cout << response.getData() << std::endl; std::cout << response.getData() << std::endl;
return 0; return 0;
} }
void test_server(std::string addr, int port, Payload p){
Connection c(addr, port);
}