Improved error handling on livestatus sockets