title: WHOIS Domain Availability Search
body: <p>I came upon the following domain check function and I can't seem to get it to work. </p>
  
  <pre><code>function domain_checker($domain){
  
  $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!";  
  }      
  </code></pre>
  
  <p>}</p>
  
  <p>I keep getting the following error:</p>
  
  <blockquote>
    <p>Warning:  fsockopen() [function.fsockopen]: unable to connect
    to whois.verisign-grs.com:43</p>
  </blockquote>
  
  <p>Help appreciated!</p>