- case I_CONNECTING:
- /* Our socket was in write-state, so delete it and re-add it
- * in read-state.
- */
-#ifndef WINDOWS
- if (this->fd > -1)
- {
- this->Instance->SE->DelFd(this);
- if (!this->Instance->SE->AddFd(this))
- return false;
- }
-#endif
- this->SetState(I_CONNECTED);
-
- if (Instance->Config->GetIOHook(this))
- {
- Instance->Log(DEBUG,"Hook for raw connect");
- try
- {
- Instance->Config->GetIOHook(this)->OnRawSocketConnect(this->fd);
- }
- catch (CoreException& modexcept)
- {
- Instance->Log(DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
- }
- }
- return this->OnConnected();
- break;
- case I_LISTENING:
- {
- /* 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* client = new sockaddr[2];
- length = sizeof (sockaddr_in);
- std::string recvip;
-#ifdef IPV6
- if ((!*this->host) || strchr(this->host, ':'))
- length = sizeof(sockaddr_in6);
-#endif
- incoming = Instance->SE->Accept(this, client, &length);
-#ifdef IPV6
- if ((!*this->host) || strchr(this->host, ':'))
- {
- char buf[1024];
- recvip = inet_ntop(AF_INET6, &((sockaddr_in6*)client)->sin6_addr, buf, sizeof(buf));
- }
- else
-#endif
- Instance->SE->NonBlocking(incoming);