PHP; replace fsocketopen function with cURL

I am using PHP to connect to a WHOIS server to query a given domain name.

I am currently using this code:

=============

     $fp = fsockopen(whois.whoever.com,43);
        fputs($fp, "domain.com\r\n");
        $string="";
        while(!feof($fp)){
                $string.= fgets($fp,128);
        }
        fclose($fp);  

=============

I need the same WHOIS response ($string) using cURL instead of fsocketopen.

Please advise.
jpschreibmanAsked:
Who is Participating?
 
hernst42Commented:
You can use fsockopen to connect to the proxy and then issue the proxy commands to connect to whois server and get the data. So instead of connection to the whois-server you connect to the proxy. Btw a http-proxy will not work for this you need a socket proxy.
0
 
hernst42Commented:
not possible. curl does not support the whois protocol.

http://curl.haxx.se/
curl is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other useful tricks.

You will need to use fsockopen
0
 
jpschreibmanAuthor Commented:
Is it possible to use fsockopen via proxy? Is so, how?
0
 
jpschreibmanAuthor Commented:
Understood and thank you.
0
 
jpschreibmanAuthor Commented:
I was attempting the impossible. Thanks anyway.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.