1#ifndef __BufferedWriter_H__
2#define __BufferedWriter_H__
22 inline void ReSet(
void);
25 inline int AddData(
const void * data,
size_t len,
Socket_TCP &sck);
26 inline int AddData(
const void * data,
size_t len);
29 template <
class SOCK_TYPE>
30 int FlushNoBlock(SOCK_TYPE &sck) {
36 int Writen = sck.SendData(GetMessageHead(),(
int)Writesize);
44 if(!sck.ErrorIs_WouldBlocking(Writen))
54 template <
class SOCK_TYPE>
55 inline int Flush(SOCK_TYPE &sck) {
60 int Writen = sck.SendData(GetMessageHead(),(
int)Writesize);
69 if(sck.ErrorIs_WouldBlocking(Writen) !=
true)
86inline Buffered_DatagramWriter::Buffered_DatagramWriter(
size_t in_size ,
int in_flush_point) :
RingBuffer(in_size) {
87 _flush_point = in_flush_point;
93inline int Buffered_DatagramWriter::AddData(
const void * data,
size_t len,
Socket_TCP &sck) {
100 answer = AddData(data,len);
103 if(answer >= 0 && _flush_point != -1)
114inline int Buffered_DatagramWriter::AddData(
const void * data,
size_t len)
118 unsigned short len1(len);
119 TS_GetInteger(len1,(
char *)&len1);
120 if(
Put((
char *)&len1,
sizeof(len1)) ==
true) {
121 if(
Put((
char *)data,len) ==
true) {
This is the buffered writer.
void ReSet(void)
used to clear the buffrers ... use of this in mid stream is a very bad thing as you can not guarany n...
bool Put(const char *data, size_t len)
Adds Data to a ring Buffer Will do a compress if needed so pointers suplied by Get Call are no longer...
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.
void ResetContent(void)
Throw away all inread information.
void FullCompress(void)
Force a compress of the data.
Base functionality for a TCP connected socket This class is pretty useless by itself but it does hide...