#ifndef NETWORK_TCP_SOCKET_H_
#define NETWORK_TCP_SOCKET_H_

#include "td/network/IPAddress.h"
#include "td/network/Socket.h"

#include <cstdint>

namespace td {
namespace network {

class TCPListener;

class TCPSocket : public Socket {
private:
	IPAddress m_RemoteIP;
	uint16_t m_Port;
	sockaddr m_RemoteAddr;

public:
	TCPSocket();
	TCPSocket(TCPSocket&& other);

	virtual bool Connect(const IPAddress& address, std::uint16_t port);
	virtual std::size_t Send(const std::uint8_t* data, std::size_t size);
	virtual DataBuffer Receive(std::size_t amount);
	virtual std::size_t Receive(DataBuffer& buffer, std::size_t amount);

	REMOVE_COPY(TCPSocket);

	friend class TCPListener;
};

void SendPacket(const DataBuffer& data, network::TCPSocket& socket);

} // ns network
} // ns td

#endif
