Support local address for TCP clients
HttpClient should allow an option to specify the local ip address. This is useful for a machine with multiple ip addresses / network interfaces. It might want to communication to happen on a specific network interface. Another use case is for a HttpClient with a really high outbound fanout and slow response (i.e. web crawler). Without an ability to force the outgoing connection to share the same local ip address and port, it will be difficult to scale the number of requests on one machine.
This may become a critical issue for our load testing as we are considering using IP address aliases (multiple IP per NIC) to overcome client port number restriction. Please consider implementing binding client to a particular IP!
noted :-)
@vietj the problem is that if the local address/port is set, you can only open at most one connection to the remote client. We might need to choose a mechanism where the client port is reused as much as possible but if the remote host/port are the same, it needs to use different local port. What do you think?
the current code only allow to set the local address in the options, the local port set is 0