Files
stvpn/tcpclient.hpp
T
2026-04-23 14:53:39 +02:00

26 lines
648 B
C++

#include <expected>
#include <string>
#include <vector>
#include <span>
#include <iostream>
class TCPClient {
private:
int sock;
int family;
public:
TCPClient();
std::expected<void, std::string> Connect(std::string address, const int port);
std::expected<int, std::string> Write(std::span<const std::byte> payload);
std::expected<int, std::string> Write(std::string payload);
std::expected<int, std::string> Read(std::vector<std::byte>* buffer);
std::expected<int, std::string> Read(std::vector<uint8_t>* buffer);
~TCPClient() {
close(sock);
}
};