When I was a kid the principal was allowed to literally beat kids with a wooden bat which seems like maybe not the best idea.
This is going to sound contradictory to what I stated previously in this subject, but, sometimes, you have to get their attention. I think it was Robert A. Heinlein that said nature gave us a way to apply pain without causing long term physical damage: the buttocks. As Robert Anton Wilson said, sometimes, pain is the only method of catching someone's attention.
Hitting a child because you are angry or upset is plain abuse. Period. Literally.
Applying some instant pressure to the buttocks can get their attention. Once you have their attention. You speak the words that you want them to retain and then you are done. If you find yourself doing this regularly, you have failed as a teacher; although to be fair, some children can be hard headed. My daughter never once required anything physical like that. My son required it something like 4 times in his whole life. The Real World is nowhere near as gentle as I was.