Files
Tower-Defense/include/network/TCPSocket.h
2023-01-02 13:05:43 +01:00

40 lines
782 B
C++

#ifndef NETWORK_TCP_SOCKET_H_
#define NETWORK_TCP_SOCKET_H_
#include "network/IPAddress.h"
#include "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