Allow specifying a socket factory for connections.

This socket factory will be used for all non-proxy connections and HTTP proxy connections.

Closes #313.