int InspSocket::Write(std::string data)
{
this->Buffer.append(data);
- this->FlushWriteBuffer();
return data.length();
}
this->state = I_ERROR;
return true;
}
- if (this->Buffer.length())
- this->FlushWriteBuffer();
+ this->FlushWriteBuffer();
return false;
}
bool InspSocket::Poll()
{
int incoming = -1;
+ bool n = true;
switch (this->state)
{
return true;
break;
case I_CONNECTED:
- return this->OnDataReady();
+ n = this->OnDataReady();
+ /* Flush any pending, but not till after theyre done with the event
+ * so there are less write calls involved. */
+ this->FlushWriteBuffer();
+ return n;
break;
default:
break;
}
-
- if (this->Buffer.length())
- this->FlushWriteBuffer();
-
return true;
}