PHP; replace fsocketopen function with cURL

Posted on 2007-10-06
Last Modified: 2010-04-21
I am using PHP to connect to a WHOIS server to query a given domain name.

I am currently using this code:


     $fp = fsockopen(,43);
        fputs($fp, "\r\n");
                $string.= fgets($fp,128);


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

Please advise.
Question by:jpschreibman
    LVL 48

    Expert Comment

    not possible. curl does not support the whois protocol.
    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

    Author Comment

    Is it possible to use fsockopen via proxy? Is so, how?
    LVL 48

    Accepted Solution

    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.

    Author Comment

    Understood and thank you.

    Author Closing Comment

    I was attempting the impossible. Thanks anyway.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now