beginExchange

Marks the start of an exchange, refusing to begin one while another is already running. Every call must be paired with endExchange in a finally.

Reads what the server sent since the last exchange before anything is written - see readUnsolicited - so a session it ended in the meantime is reported here, and nothing is sent at it.

Throws

if the server ended the session while nobody was reading.