in reply to How can I determine whether a URI, hostname or IP address is to the local host machine?

Given the existence of load balancers, you will also have to consider the possibility that the address will only sometimes be the local machine.

Why not keep a hash containing the sites you have visited. If the site you're about to visit exists in the hash, avoid recursion by not going there.

  • Comment on Re: How can I determine whether a URI, hostname or IP address is to the local host machine?
  • Download Code

Replies are listed 'Best First'.
Re^2: How can I determine whether a URI, hostname or IP address is to the local host machine?
by dbooth (Novice) on Apr 29, 2014 at 18:21 UTC
    Thanks for the thought. A hashmap of already-visited sites might work, but I am doing this from mod_perl2, which uses multiple threads for handling HTTP requests. Mod_perl2 seems to magically make each thread hold its own set of variables, and I have not yet figured out how to have a hashmap that is shared across all threads. And if I did figure out how to have a shared hashmap I would then need use some kind of locking to ensure thread safety when modifying that hashmap. So although the idea is intuitively appealing, I am concerned that it may not be so easy to implement.