XPost: comp.unix.programmer   
      
   Hi folks,   
      
   I am a newbie at network programming and have been trying to get the   
   res_search() function to work. I have searched through many man pages   
   and websites and still keep on getting a segment error. I am sure the   
   answer is fairly obvious with somone with experience but I can't seem   
   to get it to work. Here is a copy of the code I am trying to compile.   
      
      
      
   #include    
      
   #define MAXPACKETSIZE IPV6_MAXPACKET   
      
   boolean_t   
   SniffResolver()   
   {   
    // Arguments   
    const char dname = "azzmosphere.azzmos.com.au";   
    int type = T_A;   
    // end arguments   
      
    int anslen = MAXPACKETSIZE;   
    u_char *answer = malloc(MAXPACKETSIZE);   
    int ranslen = 0;   
       
    ranslen = res_search(dname, C_IN, type, answer, anslen);   
       
    syslog(LOG_DEBUG, "_res.options = '%d'", _res.options);   
    syslog(LOG_DEBUG, "ranslen = '%d'", ranslen);   
      
      
    return TRUE;   
   }   
      
      
   All the headers have been included and seem to be correct and the code   
   does compile correctly. It does produce a run time error after I   
   compile,   
      
   The debugger message I get is:   
      
   Program received signal EXC_BAD_ACCESS, Could not access memory.   
   Reason: KERN_INVALID_ADDRESS at address: 0xffffffac   
   0x9352839a in res_nsearch_2 ()   
      
      
   which to me would seem that the 'answer' variable is not correctly   
   allocated but I have used both Malloc and tried to defining as 'u_char   
   answer[MAXPACKETSIZE];' both to the same effect.   
   --   
   ....   
   "When asked what he would like on his tomb stone he said more bass"   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|