forked from jgarzik/pushpool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anet.h
45 lines (39 loc) · 1.35 KB
/
anet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef __ANET_H__
#define __ANET_H__
#include <stdbool.h>
#include "elist.h"
struct tcp_read {
void *buf; /* ptr to storage buffer */
unsigned int len; /* total storage size */
unsigned int curlen; /* amount of buffer in use */
int (*check_compl_cb)(void *, void *,
unsigned int, unsigned int *);
/* read-inf cb */
bool (*cb)(void *, void *,
unsigned int, bool); /* callback*/
void *priv; /* app-private callback arg */
struct elist_head node;
};
struct tcp_read_state {
struct elist_head q; /* read queue */
int fd; /* network socket fd */
void *priv; /* app-specific data */
void *slop;
unsigned int slop_len;
};
extern void tcp_read_init(struct tcp_read_state *rst, int fd, void *priv);
extern void tcp_read_free(struct tcp_read_state *rst);
extern bool tcp_read(struct tcp_read_state *rst,
void *buf, unsigned int buflen,
bool (*cb)(void *rst_priv, void *priv,
unsigned int, bool success),
void *priv);
extern bool tcp_read_inf(struct tcp_read_state *rst,
void *buf, unsigned int buflen,
int (*check_compl_cb)(void *, void *,
unsigned int, unsigned int *),
bool (*cb)(void *rst_priv, void *priv,
unsigned int, bool success),
void *priv);
extern bool tcp_read_runq(struct tcp_read_state *rst);
#endif /* __ANET_H__ */