Introduce a ring buffer implementation for server's network input. As a

result, clients are not disconnected due to sending large messages.
This commit is contained in:
mmdolze
2010-01-19 22:49:51 +00:00
parent 775041e81d
commit 287b933e79
7 changed files with 357 additions and 81 deletions
+22
View File
@@ -0,0 +1,22 @@
#ifndef SRING_H
#define SRING_H
/** Ring buffer data structure */
typedef struct sring_buffer_t {
char *data; /**< Dynamically allocated data storage */
unsigned int size; /**< The buffer's size */
unsigned int w; /**< write pointer */
unsigned int r; /**< read pointer */
} sring_buffer;
sring_buffer* sring_create(int iSize);
void sring_destroy(sring_buffer *buf);
void sring_clear(sring_buffer *buf);
int sring_getMaxWrite(sring_buffer *buf);
int sring_getMaxRead(sring_buffer *buf);
int sring_write(sring_buffer *buf, char *src, int src_len);
int sring_read(sring_buffer *buf, char *dst, int dst_len);
char* sring_read_string(sring_buffer *buf);
void sring_dump(sring_buffer *buf);
#endif