Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Fgets() taking over 1 min!

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

Barrucadu

Established Member
Impact
64
This code takes over 1 minute to execute, any idea why?

PHP:
<?php

$socket = fsockopen($_GET['server'], 43);
fwrite($socket, $_GET['domain']);

$found_anything = 'no';
$whois = '';

while(!feof($socket) && $found_anything != 'yes'){
	$line = fgets($socket,1024);
	if(eregi('No Match',$line) || eregi('Not Found',$line) || eregi('No Such Domain',$line)){
		$found_anything = 'yes';
	}
	$whois .= $line;
}

fclose($socket);

if(eregi('No Match',$whois) || eregi('Not Found',$whois) || eregi('No Such Domain',$whois)){
	echo 'Free';
}else{
	echo 'Taken';
}

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
try using fputs instead of fwrite
 
0
•••
Nope, still takes ages
 
0
•••
just to double check have you connected yourself to see if it takes ages to connect? And have you checked any error logs to ensure something isnt going wrong when connecting?
 
0
•••
Try:
PHP:
<?php

$socket = fsockopen($_GET['server'], 43);
fwrite($socket, $_GET['domain'] . "\r\n");

$found_anything = false;
$whois = '';

while (!feof($socket) AND !$found_anything)
{
    $line = fread($socket, 128);

    if (preg_match('#(No Match|Not Found|No Such Domain)#', $line))
    {
        $found_anything = true;
    }
    $whois .= $line;
}

fclose($socket);

echo (preg_match('#(No Match|Not Found|No Such Domain)#', $whois)) ? 'Free' : 'Taken';

?>
I tried yours, and it does take a while - the above works fine though.
 
1
•••
works perfectly SV, rep added
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: find your domains by pasting a list
You can now paste a list of domain names into the search box at the top of the Parking menu. Put one name on each line. Your domain list...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back