SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: net_dns problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    yeeeeeep
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    net_dns problem

    Hi all, I'm in a bit of a dilemma over Pear's net_dns package.
    here's my code bit

    PHP Code:
    $D = new Net_DNS();
    $res $D->resolver->query('sitepoint.com');
    print_r($res);


    if ( 
    $result->header->rcode != 'NOERROR' && $result->header->ancount ) {
      echo 
    $result->answer[0]->address;

    however, the only thing that shows up is a 0 ( zero....) can anyone tell me where i went wrong ? I've googled ard and the closest i come to an example is

    http://viebrock.ca/code/2/porting-netdig-to-netdns

    and unfortunately, his example doesnt work in my case..

    is that because i'm running a WinXP apache setup ?

    i installed pear by running go-pear.bat

    Thanks in Advance !

  2. #2
    SitePoint Zealot shenkong's Avatar
    Join Date
    Sep 2004
    Location
    China
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have your PEAR require
    DNS/
    DNS.php
    ?
    make suer the files/dir is in PEAR DIR

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    yeeeeeep
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, i required the file.

    Here's how i'm doing it

    PHP Code:
    <?
    session_start
    ();
    require 
    'DNS.php';
    $D = new Net_DNS();
    $res $D->resolver->query('sitepoint.com');
    print_r($res);
    if ( 
    $result->header->rcode!= 'NOERROR' && $result->header->ancount ) { 
        echo 
    $result->answer[0]->address

    ?>
    i turned debug mode on, and here's what i'm getting from net_dns's debug echos...

    HEADER SECTION ;; id = 40332 ;; qr = 0 opcode = QUERY aa = 0 tc = 0 rd = 1 ;; ra = 0 rcode = NOERROR ;; qdcount = 1 ancount = 0 nscount = 0 arcount = 0 ;; QUESTION SECTION (1 record) ;; sitepoint.com. IN A ;; ANSWER SECTION (0 records) ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (0 records) ;; using simple sockets

    More information.
    *
    My DNS.php is in the c:\php\PEAR folder.
    resolver, packet, rr, header, question.php is in c:\php\PEAR\NET\DNS folder
    *

    But if the path's wrong, the requires should fail, but they don't...

    And also, the query function in resolver.php is CALLED, but it's returning 0...

    Edit...
    traced the problem to an empty nameserver in the following function





    PHP Code:

    send_udp_no_sock_lib
    ($packet$packet_data)

    //trimmed//

    foreach ($this->nameservers as $nameserver) {
            echo 
    'loopy';
                 if (
    $sock[$ctr++] = fsockopen("udp://$nameserver"$this->port)) {
                    
    $peerhost[$ctr-1] = $nameserver;
                    
    $peerport[$ctr-1] = $this->port;
                    
    socket_set_blocking($sockFALSE);
                } else {
                    
    $ctr--;
                }
            }

     if (
    $ctr == 0) {
                
    $this->errorstring "no nameservers";
                return(
    NULL);
            }

    //returns NULL ....// 
    the two functions that assigns values to $nameserver is

    read_config and read_env.

    The read_config function is NOT called, and

    PHP Code:
     function read_env()
        {
            echo 
    'MEOW MEOW '.getenv("RES_NAMESERVERS").'meow';
            
            if (
    getenv("RES_NAMESERVERS")) {
                
                
    $this->nameservers split(" "getenv("RES_NAMESERVERS"));
            }

    //trimmed// 
    RES_NAMESERVERS came up empty.......


    Thanks again
    Last edited by chaosTheory; Oct 9, 2004 at 00:24.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •