- hostent* hoste = gethostbyname(host.c_str());
- if (!hoste) {
- ip = (char*)host.c_str();
- } else {
- struct in_addr* ia = (in_addr*)hoste->h_addr;
- ip = inet_ntoa(*ia);
+ this->port = port;
+
+ if (!inet_aton(host.c_str(),&addy))
+ {
+ log(DEBUG,"Attempting to resolve %s",this->host.c_str());
+ /* Its not an ip, spawn the resolver */
+ this->dns.SetNS(std::string(Config->DNSServer));
+ this->dns.ForwardLookupWithFD(host,fd);
+ timeout_end = time(NULL) + maxtime;
+ timeout = false;
+ this->state = I_RESOLVING;
+ socket_ref[this->fd] = this;
+ }
+ else
+ {
+ log(DEBUG,"No need to resolve %s",this->host.c_str());
+ this->IP = host;
+ timeout_end = time(NULL) + maxtime;
+ this->DoConnect();