+ int ret;
+
+ if ((m_flags & SPEED) != 0)
+ ret = GSocket_Write(m_socket, buffer, nbytes);
+ else
+ ret = DeferWrite(buffer, nbytes);
+
+ if (ret != -1)
+ m_lcount += ret;
+
+ return *this;
+}
+
+wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes)
+{
+ 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;
+
+ if (Write((char *)&msg, sizeof(msg)).LastCount() < sizeof(msg))
+ return *this;
+ if (Write(buffer, nbytes).LastCount() < nbytes)
+ 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;
+ Write((char *)&msg, sizeof(msg));
+