Пример #1
0
        public bool TrySend(byte[] buffer, int offset, int count, out ZmqErrorCode error)
        {
            if ((uint)offset > (uint)buffer.Length || (uint)count > (uint)(buffer.Length - offset))
            {
                ZmqUtil.ThrowArgOutOfRange();
            }

            if (count == 0)
            {
                error = ZmqErrorCode.None;
                return(false);
            }

            fixed(byte *pBuf = &buffer[0])
            {
                while (true)
                {
                    var length = ZmqNative.send(_handle, pBuf + offset, (IntPtr)count, 0);
                    if (length >= 0)
                    {
                        error = ZmqErrorCode.None;
                        return(true);
                    }

                    error = ZmqNative.errno();
                    if (error == ZmqErrorCode.EINTR)
                    {
                        continue;
                    }

                    return(false);
                }
            }
        }