public int indexOfSocket(CustomSocket socket) {

		int result = 0;
		while ((result < this.adapters.size()) && (this.adapters.get(result).getSocket() != socket))
			result++;

		// create a new frame adapter
		if (result == this.adapters.size()) {
			AuthFrameAdapter newAdapter = new AuthFrameAdapter(socket, adapterListener);
			newAdapter.setSessionID(getNewSessionID());

			this.adapters.add(newAdapter);
			result = this.adapters.indexOf(newAdapter);

			if (serverListener != null)
				serverListener.createAdapter(this, newAdapter);
		}

		return result;
	}