1 #ifndef __BufferedWriter_H__
2 #define __BufferedWriter_H__
4 #include "ringbuffer.h"
23 inline void ReSet(
void);
27 inline int AddData(
const void * data,
size_t len);
30 template <
class SOCK_TYPE>
31 int FlushNoBlock(SOCK_TYPE &sck) {
34 size_t Writesize = AmountBuffered();
37 int Writen = sck.SendData(GetMessageHead(),(
int)Writesize);
41 if(AmountBuffered() > 0)
45 if(!sck.ErrorIs_WouldBlocking(Writen))
55 template <
class SOCK_TYPE>
56 inline int Flush(SOCK_TYPE &sck) {
58 size_t Writesize = AmountBuffered();
61 int Writen = sck.SendData(GetMessageHead(),(
int)Writesize);
66 if(AmountBuffered() > 0)
70 if(sck.ErrorIs_WouldBlocking(Writen) !=
true)
94 inline Buffered_DatagramWriter::Buffered_DatagramWriter(
size_t in_size ,
int in_flush_point) :
RingBuffer(in_size) {
95 _flush_point = in_flush_point;
109 if(len > BufferAvailabe())
116 if(answer >= 0 && _flush_point != -1)
117 if(_flush_point < (
int)AmountBuffered())
134 if(BufferAvailabe() > len+2) {
135 unsigned short len1(len);
136 TS_GetInteger(len1,(
char *)&len1);
137 if(Put((
char *)&len1,
sizeof(len1)) ==
true) {
138 if(Put((
char *)data,len) ==
true) {
146 #endif //__BufferedWriter_H__
Base functionality for a TCP connected socket This class is pretty useless by itself but it does hide...
int AddData(const void *data, size_t len, Socket_TCP &sck)
Return type : inline int Argument : const void * data Argument : int len Argument : Socket_TCP &sck...
This is the buffered writer.
This is an implemention of the membuffer with ring buffer interface on it....
void ReSet(void)
used to clear the buffrers ...