Jump to content

Whois Script -- Fgets not returning anything.


jscix

Recommended Posts

The issue seems to be in the fgets loop, It hangs up for a decent time (i'd say 30-40 seconds), then sucessfully ends but the variable will contain no data.

 

I've tried the same loop, on an FTP port on my server and it sucessfully retreives data.. so i'm not positive what the problem is... Anyone see the problem or have some suggestions??

 

 


$wserver = "rs.internic.net";
$domainn = "testwhatever.com";

$cwhois  = @fsockopen("udp://" . $wserver, 43, $errn, $errstr, 30) or die("$errn - $errstr");
print "connected<br>";

fputs($cwhois, $domainn . "\r\n") or die("error sending request");
print "sent request<br>";

while (!feof($cwhois)) {
    $result .= fgets($cwhois, 200);
}
fclose($cwhois);
print "closed connection<br>";


if (eregi("No match for", $result)) {
    print "available";
} else {
    print "taken";
}

Link to comment
Share on other sites

Maybe try using fread() instead of fgets(), since fgets() only gets 1 line at a time while fread() gets the total number of bytes regardless of line breaks.. Might want to read more than 200 bytes also, such as fread($cwhois, 4096)..

 

The only other thing I can think of is to try setting the socket timeout using stream_set_timeout($cwhois, 5) .. Your fsockopen() already specifies a 30 second timeout for connecting, but maybe the stream timeout would help too..

 

Good luck with it!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.