java
setSocket(connect(host, 5222));
if (getSocket() == null) {
throw new java.io.IOException(connectError);
}
setConnection(new com.jabberwookie.Client2Server(getSocket()
.getInputStream(), getSocket().getOutputStream()));
if (!getConnection().open(host, 60000)) {
throw new java.io.IOException("Could not establish stream to "
+ host + ":5222 after 60 seconds");
}
java
Socket s = null;
try {
InetAddress[] hosts = InetAddress.getAllByName(host);
java.util.Stack exceptions = new java.util.Stack();
for (int i = 0; i < hosts.length; i++) {
try {
s = new Socket(hosts[i], port);
break;
} catch (Exception e) {
exceptions.push(e);
}
}
StringBuffer sb = new StringBuffer();
while (!exceptions.empty()) {
sb.append(((Exception) exceptions.pop()).getMessage());
}
connectError = sb.toString();
} catch (Exception e) {
connectError = e.getMessage() + " at DefaultJabber.connect(" + host
+ ", " + port + ")";
}
return s;