Exemple #1
0
        private bool OneByteSizeReady()
        {
            m_tmpbuf.Reset();

            //  First byte of size is read. If it is 0xff read 8-byte size.
            //  Otherwise allocate the buffer for message data and read the
            //  message data into it.
            byte first = m_tmpbuf[0];

            if (first == 0xff)
            {
                NextStep(m_tmpbuf, 8, EightByteSizeReadyState);
            }
            else
            {
                //  There has to be at least one byte (the flags) in the message).
                if (first == 0)
                {
                    DecodingError();
                    return(false);
                }

                //  in_progress is initialised at this point so in theory we should
                //  close it before calling zmq_msg_init_size, however, it's a 0-byte
                //  message and thus we can treat it as uninitialised...
                if (m_maxmsgsize >= 0 && (long)(first - 1) > m_maxmsgsize)
                {
                    DecodingError();
                    return(false);
                }
                else
                {
                    m_inProgress.InitPool(first - 1);
                }

                NextStep(m_tmpbuf, 1, FlagsReadyState);
            }
            return(true);
        }
Exemple #2
0
        private bool OneByteSizeReady()
        {
            m_tmpbuf.Reset();

            //  Message size must not exceed the maximum allowed size.
            if (m_maxmsgsize >= 0)
            {
                if (m_tmpbuf[0] > m_maxmsgsize)
                {
                    DecodingError();
                    return(false);
                }
            }

            //  in_progress is initialised at this point so in theory we should
            //  close it before calling zmq_msg_init_size, however, it's a 0-byte
            //  message and thus we can treat it as uninitialised...
            m_inProgress.InitPool(m_tmpbuf[0]);

            m_inProgress.SetFlags(m_msgFlags);
            NextStep(m_inProgress.Data, m_inProgress.Size, MessageReadyState);

            return(true);
        }