refactor socket and listener into services