working commit

This commit is contained in:
2026-04-23 12:28:36 +02:00
parent 04ad3a724b
commit fa1c3ce9e2
5 changed files with 181 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
#include <expected>
#include <string>
#include <vector>
#include <span>
#include <iostream>
#include <tcpclient.hpp>
int main( int argc, char** argv) {
TCPClient client;
auto res = client.conn("209.51.188.116", 80);
if (!res) {
std::cerr << res.error() << std::endl;
return 1;
}
auto wSize = client.writeBytes("GET / HTTP/1.1\n\n\n");
if (!wSize) {
std::cerr << wSize.error() << std::endl;
return 1;
}
std::vector<uint8_t> buffer;
buffer.resize(2048);
auto rSize = client.readBytes(&buffer);
if (!rSize) {
std::cerr << rSize.error() << std::endl;
return 1;
}
std::cout << rSize.value() << std::endl;
std::string s(buffer.begin(), buffer.end());
std::cout << std::format("{}", s) << std::endl;
}