1In a medium saucepan, whisk together sugar, cocoa powder, flour, and salt.
Gradually add milk to the saucepan, stirring constantly to ensure the mixture remains smooth and free of lumps.
Place the saucepan over medium heat and cook the mixture, stirring constantly, until it thickens and comes to a boil.
Allow the mixture to boil for 1 minute, then remove the saucepan from the heat.
Stir in the vanilla extract.
Pour the pudding into individual serving dishes or a large bowl.
Place plastic wrap directly on the surface of the pudding to prevent a skin from forming.
Refrigerate the pudding until it is set and chilled, about 2 hours.
Serve the chocolate pudding chilled, optionally garnished with whipped cream or chocolate shavings.