15 #include "datagramTCPHeader.h" 16 #include "netDatagram.h" 17 #include "datagramIterator.h" 18 #include "config_net.h" 31 switch (header_size) {
35 case datagram_tcp16_header_size:
37 PN_uint16 size = str.length();
38 nassertv(size == str.length());
43 case datagram_tcp32_header_size:
45 PN_uint32 size = str.length();
46 nassertv(size == str.length());
55 nassertv((
int)_header.
get_length() == header_size);
67 _header(data, header_size)
80 switch (header_size) {
84 case datagram_tcp16_header_size:
87 case datagram_tcp32_header_size:
103 if (header_size == 0) {
109 int actual_size = str.length();
111 if (actual_size == expected_size) {
115 if (net_cat.is_debug()) {
117 <<
"Invalid datagram! Size is " << actual_size
118 <<
" bytes, header reports " << expected_size <<
"\n";
126 net_cat.debug() << hex.str();
A specific kind of Datagram, especially for sending across or receiving from a network.
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...
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram. ...
string get_message() const
Returns the datagram's data as a string.
size_t get_length() const
Returns the number of bytes in the datagram.