public Endpoint getEndpoint (int index)
    throws IOException
    {
	// FIXME: don't even try this if we're not the
	// current altsetting !!

	synchronized (endpoints) {
	    if (endpoints [index] == null) {
		int	offset = getOffset ();
		int	count = index;

		do {
		    offset = nextDescriptorOffset (offset);
		    if (descriptorType (offset) == TYPE_ENDPOINT)
			count--;
		} while (count >= 0 && offset > 0);
		if (offset > 0)
		    endpoints [index] = new Endpoint (this, offset);
		else {
		    // FIXME try getStdDescriptor() with TYPE_ENDPOINT,
		    // though not many devices seem to support it
		    throw new IOException ("missing endpoint descriptor");
		}
	    }
	}
	return endpoints [index];
    }