create server and client communication logic