summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/Networking/TCPClient.hpp
blob: 4e3e089fc0ffd8db162de75b66d4a3fef363d61a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

// For encryption wrappers.
#include <Security/Encryption.hpp>

// WinSocks
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")

// std::min 
#include <algorithm>

namespace Networking
{
	// A TCPClient is essentially the same as the TCPConnection counterpart on the server,
	// however, it independently handles connection.
	class TCPClient
	{
		WSADATA					m_WinSocks;
		SOCKET					m_Socket;
		sockaddr_in				m_Context;
		Wrapper::Encryption		m_Encryption;

	public:
		TCPClient() = default;

		// Connects to a remote server.
		// Also handles the initial handshake between server and client.
		bool Start(uint32_t ServerAddress, uint16_t ServerPort);

		// Kills the client.
		void Kill();

		// Wrappers for sending/receiving data.
		void SendRawBytes(ByteArray &Bytes);
		ByteArray ReceiveRawBytes();

		void SendBytes(ByteArray &Bytes);
		ByteArray ReceiveBytes();
	};
}