+bool InspSocket::DoConnect()
+{
+ log(DEBUG,"In DoConnect()");
+ if ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ {
+ log(DEBUG,"Cant socket()");
+ this->state = I_ERROR;
+ this->OnError(I_ERR_SOCKET);
+ return false;
+ }
+
+ log(DEBUG,"Part 2 DoConnect() %s",this->IP.c_str());
+ inet_aton(this->IP.c_str(),&addy);
+ addr.sin_family = AF_INET;
+ addr.sin_addr = addy;
+ addr.sin_port = htons(this->port);
+
+ int flags;
+ flags = fcntl(this->fd, F_GETFL, 0);
+ fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
+
+ if (connect(this->fd, (sockaddr*)&this->addr,sizeof(this->addr)) == -1)
+ {
+ if (errno != EINPROGRESS)
+ {
+ log(DEBUG,"Error connect() %d: %s",this->fd,strerror(errno));
+ this->OnError(I_ERR_CONNECT);
+ this->state = I_ERROR;
+ this->Close();
+ return false;
+ }
+ }
+ this->state = I_CONNECTING;
+ ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE);
+ socket_ref[this->fd] = this;
+ this->SetQueues(this->fd);
+ log(DEBUG,"Returning true from InspSocket::DoConnect");
+ return true;
+}
+
+