2

I need to resolve a large amount of IP addresses. I'm using gethostbyaddr() for it.

I just recently read about using pcntl_fork() and that if you do fork, you don't have to wait for a timeout.

Since gethostbyaddr will take a long time (30 seconds, I think) to resolve a host before timeout, is pcntl_fork practical for use with a large amount of IP addresses?

hakre
  • 193,403
  • 52
  • 435
  • 836
Steve
  • 2,936
  • 5
  • 27
  • 38
  • 4
    If this is a core component of your service, which seems like it, if you need to make a lot of those queries, I'd say a much more elaborate setup is in order here. You'll probably want a very reliable and hand-tweaked DNS server close by, which caches and queries for you. On the PHP side, a queue/worker system with hand-tuned workers seems appropriate. Just a simple `gethostbyaddr` is easy, but probably not the tool to use if this is a core functionality. – deceze Nov 15 '12 at 11:50

1 Answers1

4

You want a high-performance, asynchronous DNS library for PHP. Fortunately, Net_DNS2 is exactly that.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278