28 switch (header_size) {
32 case datagram_tcp16_header_size:
34 uint16_t size = (uint16_t)length;
35 nassertv((
size_t)size == length);
40 case datagram_tcp32_header_size:
42 uint32_t size = (uint32_t)length;
43 nassertv((
size_t)size == length);
49 nassert_raise(
"invalid header size");
53 nassertv((
int)_header.
get_length() == header_size);
62 _header(data, header_size)
72 switch (header_size) {
76 case datagram_tcp16_header_size:
79 case datagram_tcp32_header_size:
92 if (header_size == 0) {
99 if (actual_size == expected_size) {
103 if (net_cat.is_debug()) {
105 <<
"Invalid datagram! Size is " << actual_size
106 <<
" bytes, header reports " << expected_size <<
"\n";
111 std::ostringstream hex;
114 net_cat.debug() << hex.str();
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
size_t get_length() const
Returns the number of bytes in the datagram.
void dump_hex(std::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(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
A specific kind of Datagram, especially for sending across or receiving from a network.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.