fix: several error handling issues in send/recv