- // In case the last call was an error ...
- if (ret < 0)
- m_lcount ++;
- }
- else if (m_flags & SPEED) // SPEED && !WAITALL
- {
- ret = GSocket_Write(m_socket, buffer, nbytes);
-
- if (ret > 0)
- m_lcount += ret;
- }
- else // !SPEED
- {
- ret = DeferWrite(buffer, nbytes);
-
- if (ret > 0)
- m_lcount += ret;
- }
-
- // If we have written some data, then it is not an error,
- // even when in WAITALL mode, the last low-level IO call
- // might have failed.
- if (!m_lcount)
- m_error = TRUE;
-
- return *this;
-}
-
-wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, wxUint32 nbytes)
-{
- int old_flags;
- struct {
- char sig[4];
- char len[4];
- } msg;
-
- // warning about 'cast truncates constant value'
-#ifdef __VISUALC__
- #pragma warning(disable: 4310)
-#endif // __VISUALC__
-
- msg.sig[0] = (char) 0xad;
- msg.sig[1] = (char) 0xde;
- msg.sig[2] = (char) 0xed;
- msg.sig[3] = (char) 0xfe;
-
- msg.len[0] = (char) nbytes & 0xff;
- msg.len[1] = (char) (nbytes >> 8) & 0xff;
- msg.len[2] = (char) (nbytes >> 16) & 0xff;
- msg.len[3] = (char) (nbytes >> 24) & 0xff;
-
- // GRG: We need WAITALL | SPEED
- old_flags = m_flags;
- SetFlags(WAITALL | SPEED);
-
- if (Write((char *)&msg, sizeof(msg)).LastCount() < sizeof(msg))
- {
- SetFlags(old_flags);
- m_error = TRUE;
- return *this;
- }
- if (Write(buffer, nbytes).LastCount() < nbytes)
- {
- SetFlags(old_flags);
- m_error = TRUE;
- return *this;
- }
-
- msg.sig[0] = (char) 0xed;
- msg.sig[1] = (char) 0xfe;
- msg.sig[2] = (char) 0xad;
- msg.sig[3] = (char) 0xde;
- msg.len[0] = msg.len[1] = msg.len[2] = msg.len[3] = (char) 0;
-
- if (Write((char *)&msg, sizeof(msg)).LastCount() < sizeof(msg))
- m_error = TRUE;
-
- SetFlags(old_flags);
- return *this;