FileDocCategorySizeDatePackage
MultiHostSocketFactory.javaAPI DocExample2558Thu Feb 04 16:10:36 GMT 1999None

MultiHostSocketFactory

public class MultiHostSocketFactory extends Object

Fields Summary
private Socket
sock
private Thread
target
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

	    System.out.println("Got " +
		new MultiHostSocketFactory().makeSocket(args, 7));
	
public java.net.SocketmakeSocket(java.lang.String[] hosts, int port)

		int i;
		sock = null;
		synchronized(this) {
			for (i = 0; i < hosts.length && sock == null; i++) {
				ConnectThread th =
						new ConnectThread(hosts[i], 
port, this);
				target = th;
				th.start();
				try {
				    wait(30 * 1000);
				} catch (InterruptedException ie) {}
				if (sock == null)
					th.interrupt();
			}
		}
		return sock;