- wxUint32 total;
- bool error;
- int old_flags;
- struct {
- unsigned char sig[4];
- unsigned char len[4];
- } msg;
-
- // Mask write events
- m_writing = TRUE;
-
- error = TRUE;
- total = 0;
- old_flags = m_flags;
- SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
-
- // warning about 'cast truncates constant value'
-#ifdef __VISUALC__
-# pragma warning(disable: 4310)
-#endif // __VISUALC__
-
- msg.sig[0] = (unsigned char) 0xad;
- msg.sig[1] = (unsigned char) 0xde;
- msg.sig[2] = (unsigned char) 0xed;
- msg.sig[3] = (unsigned char) 0xfe;
-
- msg.len[0] = (unsigned char) nbytes & 0xff;
- msg.len[1] = (unsigned char) (nbytes >> 8) & 0xff;
- msg.len[2] = (unsigned char) (nbytes >> 16) & 0xff;
- msg.len[3] = (unsigned char) (nbytes >> 24) & 0xff;
-
- //wxLogMessage("Writemsg: %d %d %d %d -> %d",
- // nbytes & 0xff,
- // (nbytes >> 8) & 0xff,
- // (nbytes >> 16) & 0xff,
- // (nbytes >> 24) & 0xff,
- // nbytes
- // );
-
- if (_Write((char *)&msg, sizeof(msg)) < sizeof(msg))
- goto exit;
-
- total = _Write(buffer, nbytes);
-
- if (total < nbytes)
- goto exit;
-
- msg.sig[0] = (unsigned char) 0xed;
- msg.sig[1] = (unsigned char) 0xfe;
- msg.sig[2] = (unsigned char) 0xad;
- msg.sig[3] = (unsigned char) 0xde;
- msg.len[0] = msg.len[1] = msg.len[2] = msg.len[3] = (char) 0;
-
- if ((_Write((char *)&msg, sizeof(msg))) < sizeof(msg))
- goto exit;
-
- // everything was OK
- error = FALSE;