*/
public synchronized XConnection connect(String connectionDescription)
throws NoConnectException, ConnectionSetupException
{
if (connected) {
throw new ConnectionSetupException("alread connected");
}
ConnectionDescriptor desc;
try {
desc = new ConnectionDescriptor(connectionDescription);
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new ConnectionSetupException(e.toString());
}
if (desc.getHost() == null) {
throw new ConnectionSetupException("host parameter missing");
}
// Try all (IPv4 and IPv6) addresses, in case this client is on a
// dual-stack host and the server process is an IPv4-only process, also
// on a dual-stack host (see Stevens, Fenner, Rudoff: "Unix Network
// Programming, Volume 1: The Sockets Networking API, 3rd Edition",
// p. 359):
InetAddress[] adr;
try {
adr = InetAddress.getAllByName(desc.getHost());
} catch (UnknownHostException e) {
throw new ConnectionSetupException(e.toString());
}
Socket socket = null;
for (int i = 0; i < adr.length; ++i) {
try {
socket = new Socket(adr[i], desc.getPort());