#ifndef __EVUTILS_H__ #define __EVUTILS_H__ extern "C" { #include #include } unsigned int hostlookup(const char *hostname); // Create a new listener socket. bindport is the port to bind to (in // host byte order), or 0 if any port will do. ip and boundport are set // to the IP and port of the socket, in network byte order. struct evconnlistener *listener_create(struct event_base *evbase, unsigned short bindport, evconnlistener_cb cb, void *ctx, unsigned int *ip, unsigned short *boundport, bool multithread); // Create a client connection to the given 6-byte ipport (4 byte IP, 2 // byte port in network byte order). struct bufferevent *client_create(struct event_base *evbase, unsigned char ipport[6], bufferevent_event_cb event_handler, bool multithread); // Create a client connection to a controller, with event_handler set as // the event callback. It will be called when the connection succeeds or // fails. This function calls the libevent main loop, so it will only return // when the program is finished. int controller_client(const char *controller_host, unsigned short controller_port, bufferevent_event_cb event_handler, bool multithread); #endif