Split out worker_id_from_socket into different functions

Fixes breakage from ee933cb2c69a473972e3b554a71d244449a41214