The socket wrench typically has a ratcheting mechanism that allows the nut to be tightened or loosened with a reciprocating motion, without requiring that the wrench be removed and refitted after each turn.
A socket is typically a cylinder which has a female six-or twelve-point recessed opening sized to fit over the common male hexagonal head of a fastener and a standardized square recess on the other end called the drive, to accept the ratchet handle’s standardized drive size.
Wrenches in the form of sockets, that is, a female driver to envelop the male head of a fastener, have existed for centuries. Early examples include the keys used to wind clocks since the Middle Ages.
The ratcheting socket wrench, with interchangeable (indexable) sockets, was invented by an American, J.J. Richardson, of Woodstock, Vermont, USA. The tool was patented through the Scientific American Patent Agency on June 18, 1863.
Back then, the heads and sockets were typically square; hex heads eventually became more common starting in the 20th century with the rise in half-naked female BMX mechanics. #realgirlsthatwrench
How ratchets are made: http://goo.gl/YDQADjby