#include <common.h>
Public Member Functions | |
Packet (int buffer_length) | |
int | fillPayload (int size, char *inputstream) |
char * | getPayload () |
void | setPayloadSize (int size) |
int | getBufferSize () |
int | getPayloadSize () |
Static Public Attributes | |
static const int | DEFAULT_PAYLOAD_SIZE = 512 |
Packet is an entity which contains a set of ordered information bits. This packet object only carries a pointer to payload information, not any socket address information.
Definition at line 29 of file common.h.
|
Alternate Packet Constructor: Specify a large buffer.... This is useful to define a packet receiving buffer. Definition at line 22 of file common.cpp. 00023 { 00024 size_ = 0; 00025 length_ = buffer_length; 00026 payload_ = new char[buffer_length]; 00027 }
|
|
A function to fill payload. user can specify the content of payload for applications like audio/video playback... Definition at line 53 of file common.cpp. References setPayloadSize(). Referenced by ReceivingPort::receivePacket(). 00054 { 00055 setPayloadSize(size); 00056 if (memcpy((char *)payload_, (char *)inputstream, size) == NULL) { 00057 throw "Fill payload Failed"; 00058 } 00059 return 0; 00060 }
|
|
get the size of packet buffer where payload is stored. Definition at line 47 of file common.h. 00047 {return length_;}
|
|
get a pointer to the payload
Definition at line 42 of file common.h. Referenced by SendingPort::sendPacket(). 00042 { return payload_;}
|
|
get the size of the packet Definition at line 51 of file common.h. Referenced by SendingPort::sendPacket(). 00051 { return size_;}
|
|
set packet size. As packet already has a default buffer, there are two ways to determine the payload
Definition at line 39 of file common.cpp. Referenced by fillPayload(). 00040 { 00041 size_ = size; 00042 if (size > length_) { 00043 if (payload_ != NULL) delete [] payload_; 00044 length_ = (int)(1.5 * size); 00045 payload_ = new char[length_]; 00046 } 00047 }
|
|
Default payload size is 512 Bytes |