You should only flash your headlights to warn others of your presence. Don’t use them to greet others, show impatience or give priority to other road users, because they could misunderstand your signal.
You may also be interested in these theory test questions