public int connect(String hostname, int port) {
		int i; 

		synchronized (servlist) {
			for (i = 0; i < mclients; i++) {
				if (servlist[i] == null)
					break;
			}
			if (i >= mclients) {
				// double the list if its too big...
				ajserverthread newlist[] = new ajserverthread[2*mclients];
				for (i = 0; i < mclients; i++) {
					newlist[i] = servlist[i];					
				}
				servlist = newlist;
				mclients = 2*mclients;
			}
			try {
				servlist[i] = new ajserverthread(hostname, port, i, this);
			} catch (IOException e) {
				servlist[i] = null;
				return -1;
			}
			(new Thread(servlist[i])).start();
			return i;
		}
	}