- size_t ret;
-
- ret = m_o_socket->Write((const char *)buffer, size).LastCount();
-
- if (ret > 0)
- m_lasterror = wxStream_NOERROR;
- else
- m_lasterror = wxStream_READ_ERR;
-
- return ret;
-
+ size_t ret = m_o_socket->Write((const char *)buffer, size).LastCount();
+ m_lasterror = m_o_socket->Error() ? wxSTREAM_WRITE_ERROR : wxSTREAM_NO_ERROR;
+ return ret;
+
+ // Patch 1476893 caused Advise to hang, needs further investigation
+#if 0
+ 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;
+#endif