15 #include "datagramUDPHeader.h"
16 #include "netDatagram.h"
17 #include "datagramIterator.h"
18 #include "config_net.h"
31 PN_uint16 checksum = 0;
32 for (
size_t p = 0; p < str.
size(); p++) {
33 checksum += (PN_uint16)(PN_uint8)str[p];
38 nassertv((
int)_header.
get_length() == datagram_udp_header_size);
63 PN_uint16 checksum = 0;
64 for (
size_t p = 0; p < str.
size(); p++) {
65 checksum += (PN_uint16)(PN_uint8)str[p];
72 if (net_cat.is_debug()) {
74 <<
"Invalid datagram!\n";
77 <<
" checksum is " << checksum <<
", header reports "
87 net_cat.debug(
false) << hex.str();
string get_message() const
Returns the datagram's data as a string.
A specific kind of Datagram, especially for sending across or receiving from a network.
size_t get_length() const
Returns the number of bytes in the datagram.
void dump_hex(ostream &out, unsigned int indent=0) const
Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values...
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
static int size()
Returns 3: the number of components of a LVecBase3.