Files
ldb/server.h

65 lines
854 B
C

#ifndef __SERVER_H__
#define __SERVER_H__
#include <pthread.h>
#include "network/chainbuffer.h"
#define BUFFER_LENGTH 4096
#define ENABLE_HTTP 0
#define ENABLE_WEBSOCKET 0
#define ENABLE_KVSTORE 1
typedef int (*RCALLBACK)(int fd);
struct conn {
int fd;
chain_buffer_t rbuf;
chain_buffer_t wbuf;
RCALLBACK send_callback;
union {
RCALLBACK recv_callback;
RCALLBACK accept_callback;
} r_action;
int is_stop;
int status;
#if 1 // websocket
char *payload;
char mask[4];
#endif
};
#if ENABLE_HTTP
int http_request(struct conn *c);
int http_response(struct conn *c);
#endif
#if ENABLE_WEBSOCKET
int ws_request(struct conn *c);
int ws_response(struct conn *c);
#endif
#if ENABLE_KVSTORE
int kvs_request(struct conn *c);
int kvs_response(struct conn *c);
#endif
#endif