tcpRegistrationLock.wait(100);
} catch (InterruptedException ignored) {
}
}
if (!tcpRegistered) {
throw new SocketTimeoutException("Connected, but timed out during TCP registration.\n"
+ "Note: Client#update must be called in a separate thread during connect.");
}
}
if (udpPort != -1) {
InetSocketAddress udpAddress = new InetSocketAddress(host, udpPort);
synchronized (updateLock) {
udpRegistered = false;
selector.wakeup();
udp.connect(selector, udpAddress);
}
// Wait for RegisterUDP reply.
synchronized (udpRegistrationLock) {
while (!udpRegistered && System.currentTimeMillis() < endTime) {
RegisterUDP registerUDP = new RegisterUDP();
registerUDP.connectionID = id;
udp.send(this, registerUDP, udpAddress);
try {
udpRegistrationLock.wait(100);
} catch (InterruptedException ignored) {
}
}
if (!udpRegistered)
throw new SocketTimeoutException("Connected, but timed out during UDP registration: " + host + ":" + udpPort);
}
}
} catch (IOException ex) {
close();
throw ex;