  This paper is about the structure of infinite primitive permutation groups
and totally disconnected locally compact groups ("tdlc groups'"). The
permutation groups we investigate are subdegree-finite (i.e. all orbits of
point stabilisers are finite). Automorphism groups of connected, locally finite
graphs are examples of subdegree-finite permutation groups.
  The tdlc groups we investigate all have a maximal subgroup that is compact
and open. Tdlc groups with few open subgroups (recently studied by
Pierre-Emmanuel Caprace and Timoth\'ee Marquis) are examples of such groups.
  We prove a classification result, and use it to show that every closed,
subdegree-finite primitive group is a primitive subgroup of a product H Wr F_1
[X] F_2 Wr ... [X] F_{m-1} Wr F_m, where H is a closed, subdegree-finite and
primitive group that is either finite or one-ended and almost topologically
simple. The groups F_i are transitive and finite and m is finite. The product
[X] here denotes the recently discovered box product, and all wreath products
here act via their product action.
  We apply this permutational result to tdlc groups. If G is a tdlc group then
it contains a compact open subgroup V. The permutation group induced by the
action of G on the coset space G/V is called the Schlichting completion of the
pair (G,V), and is denoted G//V. Knowledge of this action of G on G/V underpins
many recent influential results in tdlc theory. We show that if V is a maximal
subgroup of G, and G is non-compact, then G//V is subject to a topological
interpretation of our result for primitive groups. We use this to show that in
this case, if G//V is nondiscrete, preserves no nontrivial homogenous cartesian
decomposition on G/V, and does not split nontrivially over a compact open
subgroup, then the monolith of G//V is a nondiscrete, one-ended, topologically
simple, compactly generated tdlc group.
