NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page fgets() taking over 1 min!

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 10-13-2006, 10:50 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




fgets() taking over 1 min!


This code takes over 1 minute to execute, any idea why?
????: NamePros.com http://www.namepros.com/programming/246933-fgets-taking-over-1-min.html

PHP Code:
<?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)){
????: NamePros.com http://www.namepros.com/showthread.php?t=246933
    echo 
'Free';
}else{
    echo 
'Taken';
}

?>
Barrucadu is offline  
Old 10-13-2006, 01:33 PM   #2 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
try using fputs instead of fwrite
Peter is offline  
Old 10-13-2006, 02:16 PM THREAD STARTER               #3 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Nope, still takes ages
Barrucadu is offline  
Old 10-13-2006, 02:39 PM   #4 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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?
Peter is offline  
Old 10-13-2006, 02:43 PM   #5 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Try:
PHP Code:
<?php

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

$found_anything false;
$whois '';

while (!
feof($socket) AND !$found_anything)
{
    
$line fread($socket128);

    if (
preg_match('#(No Match|Not Found|No Such Domain)#'$line))
    {
????: NamePros.com http://www.namepros.com/showthread.php?t=246933
        
$found_anything true;
    }
    
$whois .= $line;
????: NamePros.com http://www.namepros.com/showthread.php?t=246933
}

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.
Eric is offline  
Old 10-13-2006, 02:49 PM THREAD STARTER               #6 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




works perfectly SV, rep added
Barrucadu is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:39 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger