23 lines
643 B
C++
23 lines
643 B
C++
|
|
#include <expected>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <span>
|
|
#include <iostream>
|
|
|
|
class TCPClient {
|
|
private:
|
|
int sock;
|
|
public:
|
|
TCPClient();
|
|
std::expected<void, std::string> conn(std::string address, const int port);
|
|
std::expected<int, std::string> writeBytes(std::span<const std::byte> payload);
|
|
std::expected<int, std::string> writeBytes(std::string payload);
|
|
std::expected<int, std::string> readBytes(std::vector<std::byte>* buffer);
|
|
std::expected<int, std::string> readBytes(std::vector<uint8_t>* buffer);
|
|
|
|
~TCPClient() {
|
|
close(sock);
|
|
}
|
|
};
|