refactor server side sockets a bit