*/
bool InspSocket::BindAddr(const std::string &ip)
{
- Instance->Log(DEBUG,"BindAddr(%s)", ip.c_str());
ConfigReader Conf(this->Instance);
- bool bindfail = false;
socklen_t size = sizeof(sockaddr_in);
#ifdef IPV6
bool v6 = false;
/* Are we looking for a binding to fit an ipv6 host? */
- if ((!*this->host) || strchr(this->host, ':'))
+ if ((ip.empty()) || (ip.find(':') != std::string::npos))
v6 = true;
#endif
int j = 0;
size = sizeof(sockaddr_in6);
}
else
- bindfail = true;
+ {
+ delete[] s;
+ j++;
+ continue;
+ }
}
else
{
((sockaddr_in*)s)->sin_family = AF_INET;
}
else
- bindfail = true;
+ {
+ delete[] s;
+ j++;
+ continue;
+ }
}
#else
in_addr n;
((sockaddr_in*)s)->sin_family = AF_INET;
}
else
- bindfail = true;
-#endif
- if (bindfail)
{
delete[] s;
- return false;
+ j++;
+ continue;
}
+#endif
if (bind(this->fd, s, size) < 0)
{
int result = Instance->Config->GetIOHook(this)->OnRawSocketWrite(this->fd, outbuffer[0].c_str(), outbuffer[0].length());
if (result > 0)
{
- if ((unsigned int)result == outbuffer[0].length())
+ if ((unsigned int)result >= outbuffer[0].length())
{
outbuffer.pop_front();
}
int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length());
if (result > 0)
{
- if ((unsigned int)result == outbuffer[0].length())
+ if ((unsigned int)result >= outbuffer[0].length())
{
/* The whole block was written (usually a line)
* Pop the block off the front of the queue,