Socket flat head diameter is measured on the outside of the threads.

Metric socket flat head diameter

Diameter and Thread pitch