Made socket helpers using logic from BT TOF setup.