Grease an 8x8-inch pan and line with parchment paper.
In a saucepan over medium heat, combine sugar, milk, cocoa, butter, and salt. Stir constantly until the mixture comes to a boil.
Reduce heat to low and cook without stirring until the mixture reaches 238°F (soft ball stage) on a candy thermometer.
Remove from heat and let sit undisturbed for 5 minutes.
Add vanilla extract (and nuts if using), then beat with a wooden spoon until thick and loses its shine.
Pour into the prepared pan and let cool completely before cutting into squares.