$sock = fsockopen('whois.crsnic.net', 43) or die('Error Connecting To Server.');
fputs($sock, "arcadejunk.com\\r\
");
while( !feof($sock) ) { $buffer .= fgets($sock,1024); }
fclose($sock);
Is there a way to change the above code into a curl function? cUrl works faster and can do more inquires then fsockopen can do. I would like to change my whois lookup routine into a curl whois lookup routine.
Please, help.
I have been tring to use this with no luck.
$curlPost[] = "arcadejunk.com\\r\
";
if(!$ch = curl_init('whois.crsnic.net')) {
echo "Could not connect to whois.crsnic.net";
return;
}
curl_setopt($ch, CURLOPT_PORT, 43);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_TIMEOUT, 5);
//curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $curlPost);
$data = curl_exec($ch);
echo "<pre>";
print_r(curl_getinfo($ch));
echo "<br />cURL error number: " .curl_errno($ch)."<br />";
echo "<br />cURL error: " . curl_error($ch)."<br />";
curl_close($ch);
echo "<br />$data<br />";
echo "</pre>";
I did notice a post on the libcurl website saying that the curlopt_port had a bug in it where it would not set the port correctly.
The version that is running.
libcurl/7.15.3 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6
//EDIT*******
Found it!!
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"whois.crsnic.net:43");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "arcadejunk.com\\r\
");
$data = curl_exec ($ch);
echo $data;