Ping in parallel
Posted: Mon Jul 12, 2010 9:53 pm
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
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