In a saucepan, heat the milk over medium heat until it begins to simmer. Remove it from the heat.
In a separate bowl, whisk together the sugar, egg yolks, flour, and vanilla extract until it forms a smooth paste.
Slowly pour the hot milk into the egg mixture, whisking constantly.
Return the mixture to the saucepan and cook over low heat, stirring continuously until it thickens into a custard-like consistency.
Remove from heat and let it cool.