Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Whois Port 43 Socket Won't Open


swa66 - 8:14 pm on Jan 28, 2013 (gmt 0)


Bill,
53 is DNS, I think you meant to say 43 where you said 53.

you can telnet to whois with
$ telnet whois.arin.net 43
then type (without a prompt) your question (e.g. 10.0.0.0<ENTER> ) and you get the answer.

The whois protocol is documented in RFC 3912 ( [tools.ietf.org...] )

This works (execute it on the command line) - it doesn't output html:

<?php
$fp = fsockopen( 'whois.ripe.net', 43, $errno, $errdesc);
if ($fp === false ) {
die ('Error opening the socket: '.$errno.' - '.$errdesc."\n");
}
$request='10.0.0.0'."\r\n";
if ( fputs($fp,$request) === false ) {
die ('Error writing to the socket'."\n");
}
$answer = '';
while (!feof($fp)) {
$answer .= fread($fp, 8192);
}
fclose($fp);
print ($answer);
?>

[edited by: swa66 at 8:42 pm (utc) on Jan 28, 2013]


Thread source:: http://www.webmasterworld.com/php/4539911.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com