agent, broker: more robust handling of socket errors

Undetected socket disconnections could occur in some circumstances which
would cause the agent to stop functioning.  This improves detection of
these errors and allows the agent to attempt reconnection.

Change-Id: Id5a676f47fae83db6fd0b75bd943f6a7325a8e8f
Signed-off-by: Greg Padgett <gpadgett@redhat.com>