properly handle socket errors when a command is not sent