Pull out repeated code into a parseSocketUrl function

fixes #2893