Hi,
I have some PHP code that fetches a list of IP addresses from a database, it then pings these IPs, saves results to a file, retrieves the 'cleaned' result from the file and writes the info to a database. So far so good. But then I ran into trouble...
Let's say that I do five pings with one second between each one - and I want to do that once per minute. That's not a problem when i have less than 12 IP addresses to ping. The problem is that the code is waiting for the ping to one IP to finish before it can start the next one - and that is five seconds for each ping. So if there are 15 IPs, then that's 75 seconds - and I am unable to repeat the ping every minute for each IP address.
How do I handle this? Any ideas? (hoping not to hear that I need some complicated async stuff!).
thanks!
//Anders
Ping in parallel
Moderator: General Moderators
Re: Ping in parallel
If you don't want to use ajax or something similar then I would suggest creating multiple files and running them at the same time (not really a great solution, I would probably pick a different language like c/c++ that can spawn multiple threads). Have each file "lock" the IP when it starts the ping process so each file will know which IP address are currently in progress or completed.
Ohh, also I did a search on php and threading and found this that may be useful to you: http://www.alternateinterior.com/2007/0 ... n-php.html
Ohh, also I did a search on php and threading and found this that may be useful to you: http://www.alternateinterior.com/2007/0 ... n-php.html