Non-blocking connection support.

This commit is contained in:
Ian Gulliver
2016-02-17 08:05:18 +00:00
parent a8f1cb5767
commit 0db4d15897
5 changed files with 124 additions and 96 deletions

View File

@@ -7,17 +7,18 @@
#define PARSER_STATE_LEN 256
struct backend;
struct addrinfo;
typedef bool (*parser)(struct backend *, struct packet *);
struct backend {
enum peer_type type;
struct peer peer;
char id[UUID_LEN];
int fd;
char *node;
char *service;
struct addrinfo *addrs;
struct addrinfo *addr;
struct buf buf;
char parser_state[PARSER_STATE_LEN];
parser parser;
};
void backend_init(struct backend *);
bool backend_connect(char *, char *, struct backend *, int);
bool backend_read(struct backend *);
struct backend *backend_new(char *node, char *service, int epoll_fd);