Adds initSocket function.