Socket cap diameter is measured on the outside of the threads.

Metric socket cap diameter

Diameter and Thread pitch