Hi,
You can start the script off by doing the regular socket connect and read the data. So, for .it domains:
$sd = fsockopen("whois.nic.it", 43 .... other args);
// Check to make sure socket is connected, then issue the following command...
$domain = "nic.it"; // of course you'll set the domain other ways (through html form input -- i suppose)
fputs($sd, "$domain\r\n");
$result = "";
while(!feof($sd)) {
$result .= fread($sd, 1024);
}
fclose($sd);
Now, to check whether it is available:
for .it domains, the WHOIS server responds:
"No entries found in the IT-NIC database".
So scan the $result for the string above and if it is present, then the domain is not taken. Otherwise, it will return a longer result showing more info.
In fact, if you don't care about the additional details, instead of the while(!feof($sd)) loop, replace those three lines with:
$result = fread($sd, 512);
This is because the "No entries found" string will show up within the first 512 bytes of the result. So if all you are looking for is the availability, just check the first part of the result to see if it is taken or not.
hope this helps,
-sridhar