Reimagined the socketInit function