chatting function by socket