Limit connections in libevent

I want to control the limitation of possible libevent-http connections for each process.

How can i do this?

I did not find any information in the documentation, please help!

I think that if I did not limit the number of connections, the system might work. The project is very heavy load.

ev_base = event_init(); ev_http = evhttp_new(ev_base); // limit http connections here... how can i do that? 
+4
source share
1 answer
 struct evconnlistener * evconnlistener_new(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, evutil_socket_t fd) 

The guarantee is that you want to change. Inside they call:

 listen(fd, backlog) 

However, in their http library they record a lag of up to 128:

 evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port) { [...] if (listen(fd, 128) == -1) { event_sock_warn(fd, "%s: listen", __func__); evutil_closesocket(fd); return (NULL); } [...] } 
+3
source

All Articles