- const char *buf = (const char *)buffer;
- size_t count = 0;
-
- while ( count < size && m_o_socket->WaitForWrite() )
- {
- const size_t ret = m_o_socket->Write(buf, size - count).LastCount();
-
- buf += ret;
- count += ret;
-
- if ( m_o_socket->Error() )
- {
- if (m_o_socket->LastError() != wxSOCKET_WOULDBLOCK)
- {
- m_lasterror = wxSTREAM_WRITE_ERROR;
- return count;
- }
- }
- }
-
- m_lasterror = wxSTREAM_NO_ERROR;
- return count;
+ const size_t ret = m_o_socket->Write(buffer, size).LastCount();
+ m_lasterror = m_o_socket->Error()
+ ? m_o_socket->IsClosed() ? wxSTREAM_EOF
+ : wxSTREAM_WRITE_ERROR
+ : wxSTREAM_NO_ERROR;
+ return ret;