String h = cfg.get ("host");
int port = cfg.getInt ("port");
maxPacketLength = cfg.getInt ("max-packet-length", 100000);
if (h != null && h.length() > 0) {
if (port == 0)
throw new ConfigurationException
("invalid port for host '"+h+"'");
setHost (h, port);
setLocalAddress (cfg.get("local-iface", null),cfg.getInt("local-port"));
String[] altHosts = cfg.getAll ("alternate-host");
int[] altPorts = cfg.getInts ("alternate-port");
hosts = new String[altHosts.length + 1];
ports = new int[altPorts.length + 1];
if (hosts.length != ports.length) {
throw new ConfigurationException (
"alternate host/port misconfiguration"
);
}
hosts[0] = host;
ports[0] = port;
System.arraycopy (altHosts, 0, hosts, 1, altHosts.length);
System.arraycopy (altPorts, 0, ports, 1, altPorts.length);
}
setOverrideHeader(cfg.getBoolean ("override-header", false));
keepAlive = cfg.getBoolean ("keep-alive", false);
expectKeepAlive = cfg.getBoolean ("expect-keep-alive", false);
if (socketFactory != this && socketFactory instanceof Configurable)
((Configurable)socketFactory).setConfiguration (cfg);
try {
setTimeout (cfg.getInt ("timeout", DEFAULT_TIMEOUT));
connectTimeout = cfg.getInt ("connect-timeout", timeout);
} catch (SocketException e) {
throw new ConfigurationException (e);
}
}