create simple connection manager, encapsulate client server code

If connection manager should have more responsibilities let me now how its public interface should look like.