Hi, In order to open more than 2^16 connections (HTTP connections in my case) *from* one machine, you need to use multiple local IPs, because the maximum local port number is 65536. evhttp_connection_set_local_address already exists and is suitable for this.
The ephemeral port allocator, which is used when you don't specify a local port numbebr, doesn't distinguish between local addresses though, so you need to specify the local port manually. I added "evhttp_connection_set_local_port", which in conjunction with evhttp_connection_set_local_address and some tcp/kernel tuning allowed me to open 1 million http connections from one machine. I brought up 16 IPs and opened 62,500 from each. Please find my patch attached - if there's svn/git/something repo I should patch against instead of the release tarball I would be happy to do so. Thanks, RJ
diff libevent-1.4.8-stable/evhttp.h libevent-1.4.8-stable-rj-clean/evhttp.h 269a270,273 > /** sets the local port from which http connections are made */ > void evhttp_connection_set_local_port(struct evhttp_connection *evcon, > u_short port); > diff libevent-1.4.8-stable/http.c libevent-1.4.8-stable-rj-clean/http.c 1040a1041,1048 > void > evhttp_connection_set_local_port(struct evhttp_connection *evcon, > u_short port) > { > assert(evcon->state == EVCON_DISCONNECTED); > evcon->bind_port = port; > } > 1654a1663 > evcon->bind_port = 0; /* by default, use ephemeral local port */ 1734c1743 < evcon->fd = bind_socket(evcon->bind_address, 0 /*port*/, 0 /*reuse*/); --- > evcon->fd = bind_socket(evcon->bind_address, evcon->bind_port, 0 > /*reuse*/); diff libevent-1.4.8-stable/http-internal.h libevent-1.4.8-stable-rj-clean/http-internal.h 63a64 > u_short bind_port; /* port to use for binding the src */
_______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users