Panda3D
Public Member Functions | Static Public Member Functions

NetDatagram Class Reference

A specific kind of Datagram, especially for sending across or receiving from a network. More...

Inheritance diagram for NetDatagram:
Datagram TypedObject MemoryBase

List of all members.

Public Member Functions

 NetDatagram ()
 Constructs an empty datagram.
 NetDatagram (Datagram const copy)
 NetDatagram (NetDatagram const copy)
 addBeFloat32 (float value)
 Adds a 32-bit single-precision big-endian floating-point number to the datagram.
 addBeFloat64 (double value)
 Adds a 64-bit big-endian floating-point number to the datagram.
 addBeInt16 (short int value)
 Adds a signed 16-bit big-endian integer to the datagram.
 addBeInt32 (int value)
 Adds a signed 32-bit big-endian integer to the datagram.
 addBeInt64 (long int value)
 Adds a signed 64-bit big-endian integer to the datagram.
 addBeUint16 (unsigned short int value)
 Adds an unsigned 16-bit big-endian integer to the datagram.
 addBeUint32 (unsigned int value)
 Adds an unsigned 32-bit big-endian integer to the datagram.
 addBeUint64 (unsigned long int value)
 Adds an unsigned 64-bit big-endian integer to the datagram.
 addBool (bool value)
 Adds a boolean value to the datagram.
 addFixedString (string str, unsigned int size)
 Adds a fixed-length string to the datagram.
 addFloat32 (float value)
 Adds a 32-bit single-precision floating-point number to the datagram.
 addFloat64 (double value)
 Adds a 64-bit floating-point number to the datagram.
 addInt16 (short int value)
 Adds a signed 16-bit integer to the datagram.
 addInt32 (int value)
 Adds a signed 32-bit integer to the datagram.
 addInt64 (long int value)
 Adds a signed 64-bit integer to the datagram.
 addInt8 (signed char value)
 Adds a signed 8-bit integer to the datagram.
 addString (string str)
 Adds a variable-length string to the datagram.
 addString32 (string str)
 Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings.
 addUint16 (unsigned short int value)
 Adds an unsigned 16-bit integer to the datagram.
 addUint32 (unsigned int value)
 Adds an unsigned 32-bit integer to the datagram.
 addUint64 (unsigned long int value)
 Adds an unsigned 64-bit integer to the datagram.
 addUint8 (unsigned char value)
 Adds an unsigned 8-bit integer to the datagram.
 addWstring (string str)
 Adds a variable-length wstring to the datagram.
 addZString (string str)
 Adds a variable-length string to the datagram, as a NULL-terminated string.
 appendData (string data)
 Appends some more raw data to the end of the datagram.
 clear ()
 Resets the datagram to empty, in preparation for building up a new datagram.
 copyArray (ConstPointerToArrayunsigned char data)
 Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar.
 dumpHex (ostream out, unsigned int indent)
 Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.
 dumpHex (ostream out)
 Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.
NetAddress const getAddress ()
 Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.
ConstPointerToArrayunsigned char getArray ()
 Returns a const pointer to the actual data in the Datagram.
Connection getConnection ()
 Retrieves the socket from which the datagram was read, or to which it is scheduled to be written.
 getData ()
 Returns a pointer to the beginning of the datagram's data.
unsigned int getLength ()
 Returns the number of bytes in the datagram.
string getMessage ()
 Returns the datagram's data as a string.
TypeHandle getType ()
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly.
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type.
PointerToArrayunsigned char modifyArray ()
 Returns a modifiable pointer to the actual data in the Datagram.
bool operator!= (Datagram const other)
bool operator< (Datagram const other)
NetDatagram operator= (NetDatagram const copy)
NetDatagram operator= (Datagram const copy)
bool operator== (Datagram const other)
 output (ostream out)
 Write a string representation of this instance to <out>.
 padBytes (unsigned int size)
 Adds the indicated number of zero bytes to the datagram.
 setAddress (NetAddress const address)
 Specifies the host to which the datagram should be sent.
 setArray (PointerToArrayunsigned char data)
 Replaces the data in the Datagram with the data in the indicated PTA_uchar.
 setConnection (Connection connection)
 Specifies the socket to which the datagram should be written.
 write (ostream out)
 Write a string representation of this instance to <out>.
 write (ostream out, unsigned int indent)
 Write a string representation of this instance to <out>.

Static Public Member Functions

static TypeHandle getClassType ()

Detailed Description

A specific kind of Datagram, especially for sending across or receiving from a network.

It's different only in that it knows which Connection and/or NetAddress it is to be sent to or was received from.


Constructor & Destructor Documentation

Constructs an empty datagram.

NetDatagram ( Datagram const  copy)
NetDatagram ( NetDatagram const  copy)

Member Function Documentation

addBeFloat32 ( float  value) [inherited]

Adds a 32-bit single-precision big-endian floating-point number to the datagram.

Since this kind of float is not necessarily portable across different architectures, special care is required.

addBeFloat64 ( double  value) [inherited]

Adds a 64-bit big-endian floating-point number to the datagram.

addBeInt16 ( short int  value) [inherited]

Adds a signed 16-bit big-endian integer to the datagram.

addBeInt32 ( int  value) [inherited]

Adds a signed 32-bit big-endian integer to the datagram.

addBeInt64 ( long int  value) [inherited]

Adds a signed 64-bit big-endian integer to the datagram.

addBeUint16 ( unsigned short int  value) [inherited]

Adds an unsigned 16-bit big-endian integer to the datagram.

addBeUint32 ( unsigned int  value) [inherited]

Adds an unsigned 32-bit big-endian integer to the datagram.

addBeUint64 ( unsigned long int  value) [inherited]

Adds an unsigned 64-bit big-endian integer to the datagram.

addBool ( bool  value) [inherited]

Adds a boolean value to the datagram.

addFixedString ( string  str,
unsigned int  size 
) [inherited]

Adds a fixed-length string to the datagram.

If the string given is less than the requested size, this will pad the string out with zeroes; if it is greater than the requested size, this will silently truncate the string.

addFloat32 ( float  value) [inherited]

Adds a 32-bit single-precision floating-point number to the datagram.

Since this kind of float is not necessarily portable across different architectures, special care is required.

addFloat64 ( double  value) [inherited]

Adds a 64-bit floating-point number to the datagram.

addInt16 ( short int  value) [inherited]

Adds a signed 16-bit integer to the datagram.

addInt32 ( int  value) [inherited]

Adds a signed 32-bit integer to the datagram.

addInt64 ( long int  value) [inherited]

Adds a signed 64-bit integer to the datagram.

addInt8 ( signed char  value) [inherited]

Adds a signed 8-bit integer to the datagram.

addString ( string  str) [inherited]

Adds a variable-length string to the datagram.

This actually adds a count followed by n bytes.

addString32 ( string  str) [inherited]

Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings.

addUint16 ( unsigned short int  value) [inherited]

Adds an unsigned 16-bit integer to the datagram.

addUint32 ( unsigned int  value) [inherited]

Adds an unsigned 32-bit integer to the datagram.

addUint64 ( unsigned long int  value) [inherited]

Adds an unsigned 64-bit integer to the datagram.

addUint8 ( unsigned char  value) [inherited]

Adds an unsigned 8-bit integer to the datagram.

addWstring ( string  str) [inherited]

Adds a variable-length wstring to the datagram.

addZString ( string  str) [inherited]

Adds a variable-length string to the datagram, as a NULL-terminated string.

appendData ( string  data) [inherited]

Appends some more raw data to the end of the datagram.

clear ( ) [inherited]

Resets the datagram to empty, in preparation for building up a new datagram.

copyArray ( ConstPointerToArrayunsigned char  data) [inherited]

Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar.

Unlike set_array(), a complete copy is made of the data; subsequent changes to the Datagram will *not* change the source CPTA_uchar.

dumpHex ( ostream  out,
unsigned int  indent 
) [inherited]

Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.

dumpHex ( ostream  out) [inherited]

Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.

NetAddress const getAddress ( )

Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.

ConstPointerToArrayunsigned char getArray ( ) [inherited]

Returns a const pointer to the actual data in the Datagram.

static TypeHandle getClassType ( ) [static]

Reimplemented from Datagram.

Connection getConnection ( )

Retrieves the socket from which the datagram was read, or to which it is scheduled to be written.

getData ( ) [inherited]

Returns a pointer to the beginning of the datagram's data.

unsigned int getLength ( ) [inherited]

Returns the number of bytes in the datagram.

string getMessage ( ) [inherited]

Returns the datagram's data as a string.

TypeHandle getType ( ) [inherited]

Reimplemented in AnimChannelBase.

int getTypeIndex ( ) [inherited]

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

bool isExactType ( TypeHandle  handle) [inherited]

Returns true if the current object is the indicated type exactly.

bool isOfType ( TypeHandle  handle) [inherited]

Returns true if the current object is or derives from the indicated type.

PointerToArrayunsigned char modifyArray ( ) [inherited]

Returns a modifiable pointer to the actual data in the Datagram.

bool operator!= ( Datagram const  other) [inherited]
bool operator< ( Datagram const  other) [inherited]
NetDatagram operator= ( Datagram const  copy)

Reimplemented from Datagram.

NetDatagram operator= ( NetDatagram const  copy)
bool operator== ( Datagram const  other) [inherited]
output ( ostream  out) [inherited]

Write a string representation of this instance to <out>.

padBytes ( unsigned int  size) [inherited]

Adds the indicated number of zero bytes to the datagram.

setAddress ( NetAddress const  address)

Specifies the host to which the datagram should be sent.

setArray ( PointerToArrayunsigned char  data) [inherited]

Replaces the data in the Datagram with the data in the indicated PTA_uchar.

This is assignment by reference: subsequent changes to the Datagram will also change the source PTA_uchar.

setConnection ( Connection  connection)

Specifies the socket to which the datagram should be written.

write ( ostream  out,
unsigned int  indent 
) [inherited]

Write a string representation of this instance to <out>.

write ( ostream  out) [inherited]

Write a string representation of this instance to <out>.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties