Hi people, I am trying to do a multiple domain lookup for 12 TLD's whose data is stored on 4 different servers. I had it running okay but the results were taking about 2 mins to return.
I figured this was because I was opening a connection to the server for each TLD I was checking and that if I opened a connection to the server once then checked each TLD that server had info about before closing the connection this would save time.
I came up with the following code but it only seems to return one result per each connection I open - is this because my code is rubbish or because you have to open a new connection for each TLD lookup, any help would be greatly appreciated!!!
Thanks in advance.
function CheckWhois($strDomainName, $strTLD) {
$fp = fsockopen( $strTLD[0], 43, &$errno, &$errstr, 100);
for($i=1;$i<count($strTLD);$i++){
$FullDomain=$strDomainName.".".$strTLD[$i];
fputs($fp, "$FullDomain\r\n");
// Check through response from whois server to determine availability
while(!feof($fp)) {
$buf = fgets($fp,128);
if (ereg( "NOT FOUND", $buf) and ($strTLD=="info")) {
$result[$i]= "unregistered";
}elseif (ereg( "Not found", $buf) and ($strTLD=="biz")) {
$result[$i]= "unregistered";
}elseif (ereg( "No match for ", $buf)) {
$result[$i]= "unregistered";
}else{
$result[$i]= "registered";
}
}
}//end loop
fclose($fp); //close server connection
}
return $result;