*/
SocketTimeout* Timeout;
- /** Timeout length
- */
- unsigned long timeout_val;
-
/** Socket output buffer (binary safe)
*/
std::deque<std::string> outbuffer;
/**
* This method attempts to connect to a hostname.
* This method is asyncronous.
+ * @param maxtime Number of seconds to wait, if connecting, before the connection times out and an OnTimeout() event is generated
*/
- virtual bool DoConnect();
+ virtual bool DoConnect(unsigned long maxtime);
/** Handle event from EventHandler parent class
*/
this->Instance->SE->AddFd(this);
}
-BufferedSocket::BufferedSocket(InspIRCd* SI, const std::string &ipaddr, int aport, unsigned long maxtime, const std::string &connectbindip)
+BufferedSocket::BufferedSocket(InspIRCd* SI, const std::string &ipaddr, int aport, unsigned int maxtime, const std::string &connectbindip)
{
this->cbindip = connectbindip;
this->fd = -1;
else
{
strlcpy(this->IP,host,MAXBUF);
- timeout_val = maxtime;
- if (!this->DoConnect())
+ if (!this->DoConnect(maxtime))
{
this->OnError(I_ERR_CONNECT);
this->Close();
return true;
}
-bool BufferedSocket::DoConnect()
+bool BufferedSocket::DoConnect(unsigned long maxtime)
{
/* The [2] is required because we may write a sockaddr_in6 here, and sockaddr_in6 is larger than sockaddr, where sockaddr_in4 is not. */
sockaddr* addr = new sockaddr[2];
return false;
}
- this->Timeout = new SocketTimeout(this->GetFd(), this->Instance, this, timeout_val, this->Instance->Time());
+ this->Timeout = new SocketTimeout(this->GetFd(), this->Instance, this, maxtime, this->Instance->Time());
this->Instance->Timers->AddTimer(this->Timeout);
}