1 #ifndef __BUFFEREDREADER_GM_H__ 2 #define __BUFFEREDREADER_GM_H__ 5 #include "ringbuffer.h" 10 inline unsigned short GetUnsignedShort(
char * in)
12 return *((
unsigned short *)in);
18 inline bool GetMessageFromBuffer(
Datagram &inmsg);
21 inline void ReSet(
void);
25 template <
class SOCK_TYPE>
26 inline int PumpMessageReader(
Datagram &inmsg, SOCK_TYPE &sck)
28 if(GetMessageFromBuffer(inmsg) ==
true)
30 int rp = ReadPump(sck);
36 if(GetMessageFromBuffer(inmsg) ==
true)
42 template <
class SOCK_TYPE>
43 inline int ReadPump(SOCK_TYPE &sck)
56 char * ff = GetBufferOpen();
57 int gotbytes = sck.RecvData(ff,(
int)readsize);
61 if(!sck.ErrorIs_WouldBlocking(gotbytes) )
64 nativenet_cat.error() <<
"buffered_datagram_reader:ReadPump socket read error -- " << GETERROR() <<
", " << sck.GetPeerName().get_ip_port().c_str() <<
"\n";
80 nativenet_cat.error() <<
"buffered_datagram_reader:ReadPump other end of socket closed -- " << sck.GetPeerName().get_ip_port().c_str() <<
"\n";
86 nativenet_cat.error() <<
"buffered_datagram_reader:ReadPump Yeep! buffer has no room to read to -- " << sck.GetPeerName().get_ip_port().c_str() <<
"\nBufferAvaiable = " << readsize <<
" AmountBuffered = " <<
AmountBuffered() <<
" BufferSize " <<
GetBufferSize() <<
"\n";
92 #include "buffered_datagramreader.I" 94 #endif //__BUFFEREDREADER_GM_H__ size_t GetBufferSize(void) const
Access to the BUffer Size Information.
void ReSet(void)
Reset all read content, ie.
size_t BufferAvailabe(void)
Will report amount of data that is contiguas that can be writen at the location returned by GetBuffer...
size_t AmountBuffered(void)
Will report the number of unread chars in buffer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void Compress(void)
Try and do a intelegent compress of the data space the algorithem is really stupid right know.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Buffered_DatagramReader(int in_size=8192)
Constructor.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...