private static jpvmBuffer internalAddHosts(jpvmBuffer req) {
		int i,j;
		jpvmBuffer ret = new jpvmBuffer();

		int newNum = 0;
		String newNames[] = null;
		jpvmTaskId newTids[] = null;
		boolean newValid[] = null;
		int newValidNum = 0;
		try {
		    // First, get the addresses of all new daemons
		    newNum = req.upkint();
		    newNames = new String[newNum];
		    newTids  = new jpvmTaskId[newNum];
		    newValid = new boolean[newNum];
		    for(i=0;i<newNum; i++) newNames[i] = req.upkstr();
		    req.unpack(newTids,newNum,1);
		}
		catch (jpvmException jpe) {
			log("bad AddHost call");
		    	perror("internalAddHost, "+jpe);
			return null;
		}

		// Check the validity of all new names
		jpvmBuffer pingBuf = new jpvmBuffer();
		newValidNum = newNum;
		for(i=0;i<newNum; i++) {
		    boolean valid = true;
		    try {
			jpvm.pvm_send(pingBuf,newTids[i],
				jpvmDaemonMessageTag.jpvmdPingRequest);
			jpvmMessage pingMess = jpvm.pvm_recv(newTids[i],
				jpvmDaemonMessageTag.jpvmdPingReply);
		    }
		    catch (jpvmException jpe) {
			valid = false;
			newValidNum--;
		    	perror("internalAddHost, ping, "+jpe);
		    }
		    newValid[i] = valid;
		    if(valid) 
			hosts.addTask(newTids[i],newNames[i]);
		}

		if (newValidNum<1) {
			// no hosts to add!
			ret = null;
		    	perror("internalAddHost, no hosts added");
			return ret;
		}

		// Create the message to add all daemons, new and old
		int oldNum = hosts.numTasks();
		int totalNum = oldNum + newValidNum;
		jpvmTaskId allTids[] = new jpvmTaskId[totalNum];
		jpvmTaskListRecord tmp = hosts.firstIter();

		// Pack in the old names...
		ret.pack(totalNum);
		i = 0;
		while(tmp != null) {
			allTids[i] = tmp.tid;
			ret.pack(tmp.name);
			tmp = hosts.nextIter();
			i++;
		}
		// Pack in the old names... 
		for(j=0;j<newNum;j++) if(newValid[j]) {
			allTids[i] = newTids[j];
			ret.pack(newNames[j]);
			i++;
		}

		// Pack in all of the tids...
		ret.pack(allTids,totalNum,1);
		return ret;
	}