usingSecureSocket = isSecure() && !isProxied();
// use the protocol's socket factory unless this is a secure
// proxied connection
final ProtocolSocketFactory socketFactory =
(isSecure() && isProxied()
? new DefaultProtocolSocketFactory()
: protocolInUse.getSocketFactory());
if (connectTimeout == 0) {
if (localAddress != null) {
socket = socketFactory.createSocket(host, port, localAddress, 0);
} else {
socket = socketFactory.createSocket(host, port);
}
} else {
SocketTask task = new SocketTask() {
public void doit() throws IOException {
if (localAddress != null) {
setSocket(socketFactory.createSocket(host, port, localAddress, 0));
} else {
setSocket(socketFactory.createSocket(host, port));
}
}
};
TimeoutController.execute(task, connectTimeout);
socket = task.getSocket();