2: Refactor main process socket communication