// We should NOT call isConnected() to test for a broken connection! That
// is because we may have received one or more events AND lost the connection,
// almost simultaneously. If there are any messages available for the
// caller to process, we should not throw an exception.
if (getEventCount() == 0 && !isConnected())
throw new NotConnectedException();
}