setup pub/sub, make socket return a pub, move socket initialization to main