Beispiel #1
0
        private ulong GetOptionUInt64(int option)
        {
            Contract.Requires(!Disposed);

            ulong value;

            C.size_t len = new C.size_t( Marshal.SizeOf(typeof(ulong)));

            if (C.zmq_getsockopt(m_sock, option, out value, ref len) != 0)
            {
                throw ZeroMQException.CurrentError();
            }

            return(value);
        }
Beispiel #2
0
        private string GetOptionString(int option)
        {
            Contract.Requires(!Disposed);

            C.size_t baLen = new C.size_t( 255 );
            IntPtr   baPtr = Marshal.AllocHGlobal(baLen.ToInt32());

            //Automatic marshalling of the byte array doesn't quite seem to work.

            if (C.zmq_getsockopt(m_sock, option, baPtr, ref baLen) != 0)
            {
                throw ZeroMQException.CurrentError();
            }

            byte[] baValue = new byte[baLen.ToInt32()];
            Marshal.Copy(baPtr, baValue, 0, baValue.Length);

            return(Encoding.ASCII.GetString(baValue));
        }
Beispiel #3
0
        private ulong GetOptionUInt64( int option )
        {
            Contract.Requires( !Disposed );

            ulong value;
            C.size_t len = new C.size_t( Marshal.SizeOf( typeof( ulong ) ) );

            if( C.zmq_getsockopt( m_sock, option, out value, ref len ) != 0 )
            {
                throw ZeroMQException.CurrentError();
            }

            return value;
        }
Beispiel #4
0
        private string GetOptionString( int option )
        {
            Contract.Requires( !Disposed );

            C.size_t baLen = new C.size_t( 255 );
            IntPtr baPtr = Marshal.AllocHGlobal( baLen.ToInt32() );

            //Automatic marshalling of the byte array doesn't quite seem to work.

            if( C.zmq_getsockopt( m_sock, option, baPtr, ref baLen ) != 0 )
            {
                throw ZeroMQException.CurrentError();
            }

            byte[] baValue = new byte[baLen.ToInt32()];
            Marshal.Copy( baPtr, baValue, 0, baValue.Length );

            return Encoding.ASCII.GetString( baValue );
        }