2022-06-11 11:32:27 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <mutex>
|
2022-06-22 23:37:46 -04:00
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/cross_sockets/XSocket.h"
|
2022-06-11 11:32:27 -04:00
|
|
|
|
|
|
|
/// @brief A cross platform generic socket client implementation
|
|
|
|
class XSocketClient {
|
|
|
|
public:
|
|
|
|
XSocketClient(int _tcp_port);
|
|
|
|
~XSocketClient();
|
|
|
|
|
|
|
|
XSocketClient(const XSocketClient&) = delete;
|
|
|
|
XSocketClient& operator=(const XSocketClient&) = delete;
|
|
|
|
|
|
|
|
bool connect();
|
|
|
|
void disconnect();
|
|
|
|
|
|
|
|
bool is_connected() { return client_socket != -1; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int tcp_port;
|
|
|
|
struct sockaddr_in addr = {};
|
|
|
|
int client_socket = -1;
|
|
|
|
};
|