<commit_before>#include <hydra/network/tcpclient.hpp>
#include <vector>
#include <SDL2/SDL_net.h>

using namespace Hydra::Network;

TCPClient::TCPClient() {
    this->_connected = false;
}
TCPClient::~TCPClient() {
	close();
}

bool TCPClient::initialize(char* ip, int port) {
	IPaddress ipaddr;	
	if(SDLNet_ResolveHost(&ipaddr, ip, port)) {
		return false;
	}
	
	this->_tcp = SDLNet_TCP_Open(&ipaddr);
	if(!this->_tcp) {
		const char* c = SDLNet_GetError();
		return false;
	}
	this->_msg = new char[MAX_NETWORK_LENGTH];
	this->_connected = true;
	this->_sset = SDLNet_AllocSocketSet(1);
	SDLNet_TCP_AddSocket(this->_sset, this->_tcp);
	return true;
}

int TCPClient::send(void* data, int length) {
	if (!_connected)
		return -1;
	((Packet*)data)->h.client = -7;
	return SDLNet_TCP_Send(this->_tcp, data, length);
}

std::vector<Packet*> TCPClient::receiveData() {
	static std::vector<uint8_t> data;
	std::vector<Packet*> packets;
	if (!_connected)
		return packets;

	if (SDLNet_CheckSockets(this->_sset, 0) == 1) {
		ssize_t lenTmp = SDLNet_TCP_Recv(this->_tcp, this->_msg, MAX_NETWORK_LENGTH);
		if (lenTmp <= 0) {
			close();
			return packets;
		}

		size_t offset = 0;
		size_t len = lenTmp;
		while (offset < len) {<commit_msg>Windows fix<commit_after>#include <hydra/network/tcpclient.hpp>
#include <vector>
#include <SDL2/SDL_net.h>

using namespace Hydra::Network;

TCPClient::TCPClient() {
    this->_connected = false;
}
TCPClient::~TCPClient() {
	close();
}

bool TCPClient::initialize(char* ip, int port) {
	IPaddress ipaddr;	
	if(SDLNet_ResolveHost(&ipaddr, ip, port)) {
		return false;
	}
	
	this->_tcp = SDLNet_TCP_Open(&ipaddr);
	if(!this->_tcp) {
		const char* c = SDLNet_GetError();
		return false;
	}
	this->_msg = new char[MAX_NETWORK_LENGTH];
	this->_connected = true;
	this->_sset = SDLNet_AllocSocketSet(1);
	SDLNet_TCP_AddSocket(this->_sset, this->_tcp);
	return true;
}

int TCPClient::send(void* data, int length) {
	if (!_connected)
		return -1;
	((Packet*)data)->h.client = -7;
	return SDLNet_TCP_Send(this->_tcp, data, length);
}

std::vector<Packet*> TCPClient::receiveData() {
	static std::vector<uint8_t> data;
	std::vector<Packet*> packets;
	if (!_connected)
		return packets;

	if (SDLNet_CheckSockets(this->_sset, 0) == 1) {
		int64_t lenTmp = SDLNet_TCP_Recv(this->_tcp, this->_msg, MAX_NETWORK_LENGTH);
		if (lenTmp <= 0) {
			close();
			return packets;
		}

		size_t offset = 0;
		size_t len = lenTmp;
		while (offset < len) {
{'fraction_non_alphanumeric': 0.16045380875202594, 'fraction_numerical': 0.008103727714748784, 'mean_word_length': 4.935096153846154, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5436525', 'n_tokens_mistral': 1005, 'n_tokens_neox': 935, 'n_words': 193}