The 3/8-inch hex piece is a drive plug for a non-reversible ratchet with a female opening. It gets pushed through one way or another to create a male drive plug to turn sockets with 3/8-inch hex drive female openings right or left.
The other piece is either a 1/2-inch square drive socket with a 1/2-inch square service opening (for turning 1/2-inch square-head fasteners, e.g., drain plugs, set screws, some bolts, etc), or a connector/adaptor. Hard to tell without seeing the innards. Is one end broached like a service opening and the other end the base (for a male drive stud)? EDIT: Looks like the former. Looks like in pic 1 the socket is upright, sitting on its base (with a 1/2-inch square drive opening), with the 1/2-inch square service opening up. In pic 2, the socket is upside down, sitting on the service opening with the drive end up.