tags:

views:

16

answers:

2

I'm working on creating a new type of email protocol, and in order to do that I had to set up an SRV DNS record for my domain.

In promoting this protocol, I'll need to be able to discover if a given host uses my system (and if not fall back to an older protocol).

So, is there a way to pull a DNS record (such as SRV) using PHP without using a PECL extension or running it through the linux command line (I already know I can ob_start() and system("host -t SRV hostname") but I'm looking for a better way, if it exists.)

+1  A: 

Use dns_get_record

array dns_get_record  (  string $hostname  [,  int $type = DNS_ANY  [,  array &$authns  [,  array &$addtl  ]]] )

Fetch DNS Resource Records associated with the given hostname.

nc3b
Thats only for getting an IP address, not returning DNS records.
Navarr
You are right, I fixed it :">
nc3b
Thanks, I noticed that function when I went to the function page for gethostbyname, lol. Its a new function. You've been a great help.
Navarr
A: 

Have you considered PEAR::Net_DNS?
http://pear.php.net/package/Net_DNS

As far as I can tell it uses socket connections (tcp/udp) and decodes the resolver data itself. The available methods look pretty extensive.

mario
see also http://articles.techrepublic.com.com/5100-10878_11-5234651.html
mario
When I said without PECL I also meant without PEAR. I'm on shared hosting so its kind of a pain to set either up.
Navarr
You can download PEAR classes individually. There's no need for server-wide installation through pecl or pear. It's actually quite common to use extracted PEAR classes project-locally. This one in particular is dependency-free.
mario