Move socket connection logic into child process. #3459