SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Non-Member
    Join Date
    Sep 2004
    Location
    India
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry fsockopen to curl

    Hi,

    Currently i am using this code to connect to a server get some info. and disconnect. But the problem is that its too slow and i am not sure why.

    So someone told me to use cURL to speed things up ...can anyone tell me how do i achieve the same by using cURL ?

    Thanks.

    PHP Code:
    <?
    $svr 
    "sub.main.com";
    $port 123;
    $url "someurl.com";

    $f = @fsockopen($svr$port$errno$errstr30);

    if (!
    $f)
    {
            return 
    10;
    }
    else
    {
            
    $rawoutput "";
            
    fputs($f"$url\r\n");

            while (!
    feof($f))
            {
                    
    $rawoutput .= fread($f,128);
            }

            
    fclose($f);
    }
    ?>

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Every method you use is going to do the same thing in the end -- open a connection to the server and read a response. Have you tried pinging and tracerouting to this server from yours to see if the delay is in the network?

  3. #3
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look up the PHP manual for cURL functions, it is quite simple.
    Anyways, what speed do you expect? Using a remote server to get data from will always take awhile, maybe more depending on server speeds.
    Perhaps an alternative solution is required. If you must get the data from an external source, cache the data and update at a set time interval, that way users are not affected by the slow speed.

  4. #4
    Non-Member
    Join Date
    Sep 2004
    Location
    India
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    This is basically a whois lookup script. By which a user enters a domain name and it checks the availability of the domain b connecting to the corrosponding whois server.

    Now i have taken the server list from Matt's Whois Lookup Script...its works fine also but in the end the problem is that if a user selects 5-6 extensions then it takes too much time unlike other websites which displays results much faster which also check for similar domains.

    I am only checking the user specified domain name and that is taking too much time. Check at http://www.avissoftware.com.

    Also i would like to know how to make a ping utility in php to check server's speed ?

    Thanks.

  5. #5
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could use an existing PHP script like PHPWhois.

  6. #6
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    TapanB, I see your problem now, thankyou for the explanation

    Take into consideration:
    - The domain name registrars probably have a faster server to work with
    - They probably have their own database of available domains (goes back to the caching idea I mentioned, they maintain a list, periodically run a check and updates the cached version and the clients don't wait as the script accesses this cached version in little time)
    Disclaimer: The above were my "educated" guesses.

    http://phpclasses.org has code for pinging and many other HTTP/network related utilities


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •