diff options
Diffstat (limited to 'src/connection.h')
-rw-r--r-- | src/connection.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/connection.h b/src/connection.h index c61b56451..ab68b6975 100644 --- a/src/connection.h +++ b/src/connection.h @@ -44,6 +44,7 @@ struct aeEventLoop; typedef struct connection connection; +typedef struct connListener connListener; typedef enum { CONN_STATE_NONE = 0, @@ -77,6 +78,7 @@ typedef struct ConnectionType { void (*ae_handler)(struct aeEventLoop *el, int fd, void *clientData, int mask); aeFileProc *accept_handler; int (*addr)(connection *conn, char *ip, size_t ip_len, int *port, int remote); + int (*listen)(connListener *listener); /* create/close connection */ connection* (*conn_create)(void); @@ -122,6 +124,19 @@ struct connection { int fd; }; +#define CONFIG_BINDADDR_MAX 16 + +/* Setup a listener by a connection type */ +struct connListener { + int fd[CONFIG_BINDADDR_MAX]; + int count; + char **bindaddr; + int bindaddr_count; + int port; + ConnectionType *ct; + void *priv; /* used by connection type specified data */ +}; + /* The connection module does not deal with listening and accepting sockets, * so we assume we have a socket when an incoming connection is created. * @@ -406,6 +421,11 @@ int connTypeHasPendingData(void); /* walk all the connection types and process pending data for each connection type */ int connTypeProcessPendingData(void); +/* Listen on an initialized listener */ +static inline int connListen(connListener *listener) { + return listener->ct->listen(listener); +} + /* Get accept_handler of a connection type */ static inline aeFileProc *connAcceptHandler(ConnectionType *ct) { if (ct) |