In practice, the DNS lookup works 99% of the time. If you writing something like Ajaxwhois, I'd suggest going this route. If you have a million names to check, I would do a first pass with a DNS lookup, and then maybe do a second pass on the ones which you may consider purchasing.