Exemplo n.º 1
0
 public void Disconnect(string endPoint)
 {
     CheckDisposed();
     if (endPoint == null)
     {
         throw new ArgumentNullException(nameof(endPoint));
     }
     LibZmq.zmq_disconnect(Handle, endPoint).ThrowIfLastError();
 }
Exemplo n.º 2
0
 public void Receive(ZmqMessage message, ZmqSendReceiveFlags flags = ZmqSendReceiveFlags.None)
 {
     CheckDisposed();
     if (message == null)
     {
         throw new ArgumentNullException(nameof(message));
     }
     LibZmq.zmq_msg_recv(message.DangerousGetNativeMessage(), Handle, flags).ThrowIfLastError();
 }
Exemplo n.º 3
0
 private void ReleaseUnmanagedResources()
 {
     try
     {
         LibZmq.zmq_msg_close(_nativeMessage).ThrowIfLastError();
     }
     finally
     {
         Marshal.FreeHGlobal(_nativeMessage);
         _nativeMessage = IntPtr.Zero;
     }
 }
Exemplo n.º 4
0
        public ZmqMessage(int initialSize = 0)
        {
            if (initialSize < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(initialSize));
            }

            _nativeMessage = Marshal.AllocHGlobal(Marshal.SizeOf <LibZmq.zmq_msg_t>());
            if (initialSize == 0)
            {
                LibZmq.zmq_msg_init(_nativeMessage).ThrowIfLastError();
            }
            else
            {
                LibZmq.zmq_msg_init_size(_nativeMessage, new UIntPtr((uint)initialSize)).ThrowIfLastError();
            }
        }
Exemplo n.º 5
0
 protected override int ReleaseZmqObject(IntPtr context)
 {
     return(LibZmq.zmq_ctx_term(context));
 }
Exemplo n.º 6
0
 public ZmqSocket(ZmqContext context, ZmqSocketType socketType)
 {
     Context    = context ?? throw new ArgumentNullException(nameof(context));
     SocketType = socketType;
     Handle     = LibZmq.zmq_socket(context.Handle, socketType).ThrowIfLastError();
 }
Exemplo n.º 7
0
 public IntPtr DangerousGetData()
 {
     CheckDisposed();
     return(LibZmq.zmq_msg_data(_nativeMessage));
 }
 protected override int ReleaseZmqObject(IntPtr socket) => LibZmq.zmq_close(socket);