forked from yaosj2k/dnsforwarder
-
Notifications
You must be signed in to change notification settings - Fork 9
/
socketpool.h
executable file
·40 lines (29 loc) · 902 Bytes
/
socketpool.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
#ifndef SOCKETPOOL_H_INCLUDED
#define SOCKETPOOL_H_INCLUDED
#include <time.h>
#include "bst.h"
#include "stablebuffer.h"
#include "common.h"
typedef struct _SocketUnit SocketUnit;
typedef struct _SocketPool SocketPool;
struct _SocketPool{
/* private */
Bst t;
SocketUnit *SocketUnit; /* cache: {SOCKET, Data} */
int DataLength;
/* public */
int (*Add)(SocketPool *sp,
SOCKET Sock,
const void *Data,
int DataLength
);
int (*Del)(SocketPool *sp, SOCKET Sock);
SOCKET (*FetchOnSet)(SocketPool *sp,
fd_set *fs,
void **Data
);
void (*CloseAll)(SocketPool *sp, SOCKET ExceptFor);
void (*Free)(SocketPool *sp, BOOL CloseAllSocket);
};
int SocketPool_Init(SocketPool *sp, int DataLength);
#endif /* SOCKETPOOL_H_INCLUDED */