Class that allows easy and portable handling, sending and receiving of data over a network. More...
#include "Network.hpp"
Classes | |
| struct | MessageLength |
| Message length error. More... | |
| struct | WinSockAPIError |
| WinSock error. More... | |
Public Member Functions | |
| NetDataT () | |
| Constructor. More... | |
| void | ReadBegin () |
| Initializes reading of the data buffer. More... | |
| char | ReadByte () |
| Reads one Byte (8 Bit) from the data buffer. More... | |
| unsigned short | ReadWord () |
| Read one Word (16 Bit) from the data buffer. More... | |
| uint32_t | ReadLong () |
| Reads one uint32_t from the data buffer. More... | |
| float | ReadFloat () |
| Reads one Float (32 Bit) from the data buffer. More... | |
| const char * | ReadString () |
| Reads a String from the data buffer. More... | |
| ArrayT< uint8_t > | ReadDMsg () |
| Reads a delta message for cf::Network::StateT from the data buffer. More... | |
| void | WriteByte (char b) |
| Writes one Byte (8 Bit) into the data buffer. More... | |
| void | WriteWord (unsigned short w) |
| Writes one Word (16 Bit) into the data buffer. More... | |
| void | WriteLong (uint32_t ui) |
| Writes one uint32_t into the data buffer. More... | |
| void | WriteFloat (float f) |
| Writes one float (32 Bit) into the data buffer. More... | |
| void | WriteString (const char *String) |
| Writes a String into the data buffer. More... | |
| void | WriteString (const std::string &String) |
| Writes a String into the data buffer. More... | |
| void | WriteArrayOfBytes (const ArrayT< char > &AoB) |
| Writes an ArrayT<char> into the data buffer. More... | |
| void | WriteDMsg (const ArrayT< uint8_t > &DMsg) |
| Writes a delta message as created by cf::Network::StateT into the data buffer. More... | |
| void | Send (SOCKET Socket, const NetAddressT &ReceiverAddress) const |
| Send the content of NetDataT through 'Socket' (non-blocking UDP socket) to 'ReceiverAddress'. More... | |
| NetAddressT | Receive (SOCKET Socket) |
| Receives one packet from 'Socket' (non-blocking UDP socket), overwrites the content of this NetDataT and returns the NetAddressT of the sender. More... | |
Public Attributes | |
| ArrayT< char > | Data |
| Data buffer contents. More... | |
| unsigned long | ReadPos |
| Reading position in data. More... | |
| bool | ReadOfl |
| Whether the attempt was made to read over the data buffer boundaries. More... | |
Class that allows easy and portable handling, sending and receiving of data over a network.
|
inline |
Constructor.
|
inline |
Initializes reading of the data buffer.
|
inline |
Reads one Byte (8 Bit) from the data buffer.
|
inline |
Reads a delta message for cf::Network::StateT from the data buffer.
|
inline |
Reads one Float (32 Bit) from the data buffer.
|
inline |
Reads one uint32_t from the data buffer.
|
inline |
Reads a String from the data buffer.
|
inline |
Read one Word (16 Bit) from the data buffer.
| NetAddressT NetDataT::Receive | ( | SOCKET | Socket | ) |
Receives one packet from 'Socket' (non-blocking UDP socket), overwrites the content of this NetDataT and returns the NetAddressT of the sender.
| Socket | The socket to receive the data from. |
| WinSockAPIError,when | receicing failes. |
| void NetDataT::Send | ( | SOCKET | Socket, |
| const NetAddressT & | ReceiverAddress | ||
| ) | const |
Send the content of NetDataT through 'Socket' (non-blocking UDP socket) to 'ReceiverAddress'.
| Socket | The socket to send the data through. |
| ReceiverAddress | The address of the receiver. |
| WinSockAPIError | if theres a WinSock API error |
| MessageLength | when the message was not completely sent. |
|
inline |
Writes an ArrayT<char> into the data buffer.
| AoB | Byte array to write. |
|
inline |
Writes one Byte (8 Bit) into the data buffer.
| b | Byte to write. |
|
inline |
Writes a delta message as created by cf::Network::StateT into the data buffer.
| DMsg | Delta message to write. |
|
inline |
Writes one float (32 Bit) into the data buffer.
| f | Float to write. |
|
inline |
Writes one uint32_t into the data buffer.
| ui | The 32-bit unsigned integer to write. |
|
inline |
Writes a String into the data buffer.
| String | String to write. |
|
inline |
Writes a String into the data buffer.
| String | String to write. |
|
inline |
Writes one Word (16 Bit) into the data buffer.
| w | Word to write. |
| ArrayT<char> NetDataT::Data |
Data buffer contents.
| bool NetDataT::ReadOfl |
Whether the attempt was made to read over the data buffer boundaries.
| unsigned long NetDataT::ReadPos |
Reading position in data.