- this->sock->Close();
- delete this->sock;
- return;
- }
-}
-
-bool InspSocket::Poll()
-{
- if (this->Instance->SE->GetRef(this->fd) != this)
- return false;
-
- int incoming = -1;
-
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
- return false;
-
- switch (this->state)
- {
- case I_CONNECTING:
- /* Our socket was in write-state, so delete it and re-add it
- * in read-state.
- */
- if (this->fd > -1)
- {
- this->Instance->SE->DelFd(this);
- this->SetState(I_CONNECTED);
- if (!this->Instance->SE->AddFd(this))
- return false;
- }
- if (Instance->Config->GetIOHook(this))
- {
- 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:
- length = sizeof (client);
- incoming = accept (this->fd, (sockaddr*)&client,&length);
-
-#ifdef IPV6
- this->OnIncomingConnection(incoming, (char*)insp_ntoa(client.sin6_addr));
-#else
- this->OnIncomingConnection(incoming, (char*)insp_ntoa(client.sin_addr));
-#endif