#pragma once #define _WINSOCKAPI_ #include #include #include class TCPClient { public: WSADATA wsaData; SOCKET socket; TCPClient() { } bool connect(const char* hostname, const char* port); int send(const char* buf, size_t len); bool sendAll(const char* buf, size_t len); int recv(char* buf, size_t len); bool recvUntil(char* buf, size_t len); template bool send(const T& value); template bool recv(T& value); }; template bool TCPClient::send(const T& value) { return sendAll((const char*)&value, sizeof(T)); } template bool TCPClient::recv(T& value) { return recvUntil((char*)&value, sizeof(T)); } template<> bool TCPClient::send(const std::string& value); template<> bool TCPClient::recv(std::string& value);