sending and receiving messages from server