I'm currently writing an MobileSubstrate plugin (code injection for iPhone). It gets the hostname by hooking into connect() and this piece of 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];
}
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).
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?
Thank you very much in advance.