socketFactory = config.getUsingSSL() ? SSLSocketFactory.getDefault() : SocketFactory.getDefault();
if (config.getHttpProxyHost() != null) {
socket = socketFactory.createSocket(config.getHttpProxyHost(), config.getHttpProxyPort());
connectProxy(host, port, socket);
} else {
socket = socketFactory.createSocket(host, port);
}
return new SocketConnection(socket);
} catch (Exception e) {
throw new IOException(e.getMessage());