Measurement of the γ γ → π + π − and γ γ → K + K − processes at energies of 2.4–4.1 GeV