Files
VoidNet/include/TcpClient.hpp
xX-TheDoctor-Xx 72aa8ee0c4 Got tcp receiving for windows done
Callbacks are done - maybe ill add a few more later - i dont know if they will work correctly yet
Fixed the Serialization class
Added internal tags - for now it only has CONNECT and DISCONNECT - maybe ill add more later
Fixed some data type parameters in some functions
2016-07-17 19:59:22 +01:00

47 lines
828 B
C++

#ifndef TCP_CLIENT_HPP
#define TCP_CLIENT_HPP
#include "Defs.hpp"
#include "NetworkMessage.hpp"
#include <string>
#ifdef _MSC_VER
#pragma once
#endif
class TcpClient
{
public:
TcpClient();
TcpClient(const std::string &ip, uint16 port = default_port);
~TcpClient();
const std::string &GetIP();
void SetIP(const std::string &ip);
uint16 GetPort();
void SetPort(uint16 port);
VoidCode Connect();
NetworkBuffer ReceiveDataArray();
const NetworkMessage &ReceiveData();
bool SendData(const NetworkMessage &message);
private:
VoidCode Initialize(const std::string &ip, uint16 port = default_port);
std::string ip;
uint16 port = 0;
bool initialized;
#ifdef _MSC_VER
SOCKET socket = INVALID_SOCKET;
struct addrinfo *result = nullptr;
struct addrinfo *ptr = nullptr;
struct addrinfo hints;
#endif
};
#endif