reactphp / dns

Async DNS resolver for ReactPHP.

Home Page:https://reactphp.org/dns/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: I like the pure PHP DNS client. Can I use it without the $loop in a non-PHP react project?

woutersamaey opened this issue · comments

I like the pure PHP DNS client. Can I use it without the $loop in a non-PHP react project?
Judging by the code, this does not appear to be possible, but maybe there is a mock loop or some other way to make the code blocking?

Thanks in advance.

@woutersamaey Welcome to ReactPHP, excellent question!

The loop is what keeps all our applications running, so you can't really get rid of it. As an alternative, it's quite simple to control the loop so it only keeps running until your results are ready. Take a look at https://github.com/clue/reactphp-block to block until a promise resolves, such as:

$ip = Clue\React\Block\await($resolver->resolve('reactphp.org'), $loop, 10.0);

I hope this helps 👍