There are many whois servers around the interweb, we can use such whois server to determine if an domain name is already taken or is still available to be registered. Mostly whois server are connected on port 43. Below is the php script i developed to check domains with com,net,org,info,biz and name extensions.
<?php
function checkdomain($domainname)
{
$extension = explode(".",$domainname);
$extension = $extension[1];
switch($extension)
{
case "com": $server = "whois.verisign-grs.com"; break;
case "net": $server = "whois.verisign-grs.com"; break;
case "org": $server = "whois.pir.org"; break;
case "info": $server = "whois.afilias.net"; break;
case "biz": $server = "whois.biz"; break;
case "name": $server = "whois.nic.name"; break;
default: return "Given Extension not supported"; exit();
}
// connecting to the whois server.
$handle = fsockopen($server, 43);
if (!$handle)
return false; // connectin failure
//asking the server
fwrite($handle, $domainname."\r\n");
// getting response
$response = '';
while (!feof($handle))
$response .= fgets($handle, 1024);
fclose($handle);
//checking if domain is available or not
if($extension=="com" || $extension=="net" || $extension=="name")
{
if(stripos($response, 'No match') === FALSE )
return $domainname." is not Available!";
else
return $domainname. " is Available!";
}
else
{
if(stripos($response, "NOT FOUND") === FALSE)
return $domainname. " is not Available!";
else
return $domainname. " is Available!";
}
}
echo checkdomain("anildewani.com");
echo checkdomain("anildewani.net");
echo checkdomain("anildewani.org");
echo checkdomain("anildewani.info");
echo checkdomain("anildewani.biz");
echo checkdomain("anildewani.name");
echo checkdomain("anildewani.in");
?>

I extend this code more and use google adwords so I can check top keywords have domain available or not if so then lead to godaddy with domain name.
Regards,
M.Singh