Split socketList generation into separate function