Files
VoidNet/include/VoidNet_LL/TcpClient.hpp
TheDoctor 03fad4e3d3 Update
Added Raw socket type and SocketProtocol to implement ICMP
Renamed TcpSocketBuilder to SocketBuilder
Removed UdpSocketBuilder (merged with SocketBuilder)
2019-10-21 23:29:29 +01:00

33 lines
810 B
C++

#pragma once
#include "VoidNet_LL/Socket.hpp"
namespace std::net
{
class TcpConnectionHandler;
}
namespace std::net
{
class TcpClient
{
friend class TcpConnectionHandler;
public:
TcpClient(Socket *soc);
TcpClient(AddressFamily af = AddressFamily::IPv4);
bool Connect(const IPAddress& addrStr);
bool Close() const;
bool HasPendingData(uint32_t& pendingDataSize) const;
bool Send(const byte* data, int32_t count, int32_t& sent) const;
bool Recv(byte* data, int32_t size, int32_t& read, SocketReceiveFlags flags = SocketReceiveFlags::None) const;
bool Wait(SocketWaitConditions cond, chrono::milliseconds t) const;
SocketConnectionState GetConnectionState() const;
void GetAddress(IPAddress& outAddr) const;
int32_t GetPort() const;
private:
unique_ptr<Socket> m_socket;
};
}