#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Number of loop's per minute


    Hi guys

    I am connecting to a host and looking for a specific reply using fsockopen on a loop, and all is working fine. However the host i am connecting to sets a maximum limit on the checks to around 900 per minute.

    Is there a way i can set the loop to only loop 900 times in any given minute???
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    Not sure what a "check" is. A whole new connection? Or else how do these "checks" work? When are these checks triggered: via a webpage?

    And what's your code?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Thanks for your reply. Im connecting to an domain availability checker to check the status of a domain. Until it changes the loop must constantly run (but cant exceed 900 checks per minute). Once the domain status changed the code will do something else. So the "check" i was relating to in my OP is checking the status od the domain.

    The code i have so far is

    PHP Code:
    $fp fsockopen("thehost.com" 2043 $errno $errstr 30); if (!$fp)
     {
     echo 
    "$errstr ($errno)<br />\n";
     }
    else
     {
     while (!
    feof($fp)) 
    fputs($fp "thedomainname.com\r\n");
     
    echo 
    fgets($fp 128);
     }

     
    fclose($fp);
     } 
    The remote server returns a msg in the format:

    thedomainname,com Y N N 1998-08-03 2006-3-08 4 123-REG

    Meaning the name is not available

    When it becomes available it'll return a msg in this format:

    thedomainname.com N (This is when my script will call another function)

    Like i say, the loop is running fine but its causing me to go over my 900 checks per minute.

    Any suggestions would be greatly appreciated.
  6. #4
  7. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,947
    Rep Power
    4033
    You could just add a simple sleep(1) into the loop code so it pauses for one second each iteration. There's also usleep if you want to use a shorter sleep duration.
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,989
    Rep Power
    375
    surely you are "using" their bandwidth for your own gains.. is this legit? If I were the host, I would be angry..
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Sure is legit, Only members can use their services tho and its quite pricey to become a member (ive recently just become one)

    Your limited to a maximum of 400k searches per 24 hours rolling period though
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    158
    Rep Power
    10
    Sounds like you're trying to grab a domainname by constantly polling to see if it's available yet.

    Sure you can write a script so that it counts how many times it has checked this minute, but if the network is fast enough you might burn through all your checks in 20 seconds, and thus leave your opponents 40 seconds time to grab the domain.
    I'd throttle the requests so that you spread the workload over the entire minute. You know how many domains you are trying to get so you kniow how many requests you can spend per minute per domain. Then you can build in a delay and get the optimal spread of requests accross the minute.

    Actualy I didn't think people still bothered to grab domains, with the current market penetration of poop like google I thought the domainname industry would have died by now...
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Sounds like you're trying to grab a domainname by constantly polling to see if it's available yet.
    Spot on


    Sure you can write a script so that it counts how many times it has checked this minute, but if the network is fast enough you might burn through all your checks in 20 seconds, and thus leave your opponents 40 seconds time to grab the domain.
    I'd throttle the requests so that you spread the workload over the entire minute. You know how many domains you are trying to get so you kniow how many requests you can spend per minute per domain. Then you can build in a delay and get the optimal spread of requests accross the minute.
    Thats the idea im working towards, a little stuck though lol but will get there.


    Actualy I didn't think people still bothered to grab domains, with the current market penetration of poop like google I thought the domainname industry would have died by now...
    I think your right on that but its just something for me to do in my spare time
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    158
    Rep Power
    10
    I guess it's no big deal to calculate the per-request delay if you now how much time is left in the current minute and how many requests you can still do:-)
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,989
    Rep Power
    375
    but why do you have to do it so constantly? why not try at set intervals per day? and why are you trying to get these domains? some hosts such as 123-reg allow you to "back order" a domain so it can be snapped up if it ever comes available (not free)
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Thanks for the replies, Ive created a very simple script now which seems to work well. Im going to tweak it over the coming days to try and improve its performance further.

    but why do you have to do it so constantly? why not try at set intervals per day? and why are you trying to get these domains? some hosts such as 123-reg allow you to "back order" a domain so it can be snapped up if it ever comes available (not free)
    It needs to be on a constant basis to be in with a chance of registering the domains, otherwise they would be taken by others in the same game.

    Comments on this post

    • Northie disagrees : did you close the thread? How do you know you've got the best answer? I would have said cron, once a minute, time your iteractiosn with microtime and use usleep for padding

IMN logo majestic logo threadwatch logo seochat tools logo