+wxUint32 wxSocketBase::_Write(const char *buffer, wxUint32 nbytes)
+{
+ wxUint32 total = 0;
+ int ret = 1;
+
+ if (!m_connected || !m_socket)
+ return 0;
+
+ // Possible combinations (they are checked in this order)
+ // NOWAIT
+ // SPEED | WAITALL
+ // SPEED
+ // WAITALL
+ // NONE
+ //
+ if (m_flags & NOWAIT) // NOWAIT
+ {
+ GSocket_SetNonBlocking(m_socket, TRUE);
+ ret = GSocket_Write(m_socket, buffer, nbytes);
+ GSocket_SetNonBlocking(m_socket, FALSE);
+
+ if (ret > 0)
+ total = ret;
+ }
+ else if ((m_flags & SPEED) && (m_flags & WAITALL)) // SPEED, WAITALL
+ {
+ while (ret > 0 && nbytes > 0)
+ {
+ ret = GSocket_Write(m_socket, buffer, nbytes);
+ total += ret;
+ buffer += ret;
+ nbytes -= ret;
+ }
+ // In case the last call was an error ...
+ if (ret < 0)
+ total ++;
+ }
+ else if (m_flags & SPEED) // SPEED, !WAITALL
+ {
+ ret = GSocket_Write(m_socket, buffer, nbytes);
+
+ if (ret > 0)
+ total = ret;
+ }
+ else // NONE or WAITALL
+ {
+ ret = DeferWrite(buffer, nbytes);
+
+ if (ret > 0)
+ total = ret;
+ }
+
+ return total;
+}
+
+wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, wxUint32 nbytes)