7 #ifndef NAZARA_TCPCLIENT_HPP 8 #define NAZARA_TCPCLIENT_HPP 10 #include <Nazara/Prerequesites.hpp> 11 #include <Nazara/Core/ByteArray.hpp> 12 #include <Nazara/Core/Stream.hpp> 13 #include <Nazara/Network/AbstractSocket.hpp> 14 #include <Nazara/Network/IpAddress.hpp> 30 SocketState Connect(
const IpAddress& remoteAddress);
31 SocketState Connect(
const String& hostName, NetProtocol protocol = NetProtocol_Any,
const String& service =
"http", ResolveError* error =
nullptr);
34 void EnableLowDelay(
bool lowDelay);
35 void EnableKeepAlive(
bool keepAlive, UInt64 msTime = 10000, UInt64 msInterval = 1000);
37 bool EndOfStream()
const override;
39 UInt64 GetCursorPos()
const override;
40 inline UInt64 GetKeepAliveInterval()
const;
41 inline UInt64 GetKeepAliveTime()
const;
42 inline IpAddress GetRemoteAddress()
const;
43 UInt64 GetSize()
const override;
45 inline bool IsLowDelayEnabled()
const;
46 inline bool IsKeepAliveEnabled()
const;
48 bool Receive(
void* buffer, std::size_t size, std::size_t* received);
51 bool Send(
const void* buffer, std::size_t size, std::size_t* sent);
52 bool SendMultiple(
const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent);
55 bool SetCursorPos(UInt64 offset)
override;
57 bool WaitForConnected(UInt64 msTimeout = 3000);
62 void FlushStream()
override;
64 void OnClose()
override;
65 void OnOpened()
override;
67 std::size_t ReadBlock(
void* buffer, std::size_t size)
override;
68 void Reset(SocketHandle handle,
const IpAddress& peerAddress);
69 std::size_t WriteBlock(
const void* buffer, std::size_t size)
override;
73 std::size_t received = 0;
76 bool headerReceived =
false;
80 PendingPacket m_pendingPacket;
81 UInt64 m_keepAliveInterval;
82 UInt64 m_keepAliveTime;
83 bool m_isKeepAliveEnabled;
84 bool m_isLowDelayEnabled;
88 #include <Nazara/Network/TcpClient.inl> 90 #endif // NAZARA_TCPCLIENT_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Network class that represents an IP address.
Definition: IpAddress.hpp:21
Core class that represents a string.
Definition: String.hpp:22
Network class that represents a client in a TCP connection.
Definition: TcpClient.hpp:21
Network class that represents a packet.
Definition: NetPacket.hpp:18
Core class that represents an array of bytes.
Definition: ByteArray.hpp:18
Core class that represents a stream.
Definition: Stream.hpp:19
Network class that represents a server in a TCP connection.
Definition: TcpServer.hpp:18
Network class that represents the base of socket.
Definition: AbstractSocket.hpp:18