title: iPhone, C/objC: getting hostname (not by resolving from IP) by hooking into system wide functions?
body: <p>I'm currently writing an MobileSubstrate plugin (code injection for iPhone). It gets the hostname by hooking into connect() and this piece of code:</p>
  
  <pre><code>#ifndef   NI_MAXHOST
  #define   NI_MAXHOST 1025
  #endif
  
  int error;
  
   char hostname[NI_MAXHOST] = "";
  
  
   error = getnameinfo(serv_addr, addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
  
   if (error !=0) {
    ALogTCP(@"coudldn't resolve hostname or internal connect");
  
    return orig__connect(sockfd, serv_addr, addrlen);
    }
  
  
   if (error == 0) {
    ALogTCP(@"hostname: %s", hostname);
    NSString *hostFirst = [NSString stringWithCString:hostname];
  }
  </code></pre>
  
  <p>Now I've noticed that some hostnames won't get resolved properly (wrong host: like connect.xyz.com instead of irc.xyz.com)  (depending on the DNS Server).</p>
  
  <p>I'm not very used to all the networking functions and an extensive search didn't turn up any solution.:
  I'm thinking about hooking into a function which is responsible for all hostname->IP "conversions", getting the hostname and use it later in the above code. Is there such a function? and how is it called?</p>
  
  <p>Thank you very much in advance.</p>