HttpClient Timeout

How to set up timeout for an HttpClient – connection and socket timeouts, and a mechanism for hard timeout of ongoing http connections. >>>