- 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);
- this->SetState(I_CONNECTED);
- if (!this->Instance->SE->AddFd(this))
- return false;
- }
-#else
- this->SetState(I_CONNECTED);
-#endif
- Instance->Log(DEBUG,"Inspsocket I_CONNECTING state");
- 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:
- {
- 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 = _accept (this->fd, 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
- recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr);
- this->OnIncomingConnection(incoming, (char*)recvip.c_str());
-
- if (this->IsIOHooked)
- {
- try
- {
- Instance->Config->GetIOHook(this)->OnRawSocketAccept(incoming, recvip.c_str(), this->port);
- }
- catch (CoreException& modexcept)
- {
- Instance->Log(DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
- }
- }
-
- this->SetQueues(incoming);
-
- delete[] client;
- return true;
- }
- break;
- case I_CONNECTED:
- /* Process the read event */
- return this->OnDataReady();
- break;
- default:
- break;