예제 #1
0
        // Receive a multi-part message
        //
        // Receives up to *count_ parts of a multi-part message.
        // Sets *count_ to the actual number of parts read.
        // ZMQ_RCVMORE is set to indicate if a complete multi-part message was read.
        // Returns number of message parts read, or -1 on error.
        //
        // Note: even if -1 is returned, some parts of the message
        // may have been read. Therefore the client must consult
        // *count_ to retrieve message parts successfully read,
        // even if -1 is returned.
        //
        // The iov_base* buffers of each iovec *a_ filled in by this
        // function may be freed using free().
        //
        // Implementation note: We assume zmq::msg_t buffer allocated
        // by zmq::recvmsg can be freed by free().
        // We assume it is safe to steal these buffers by simply
        // not closing the zmq::msg_t.
        //
        public int RecvIOv(SocketBase s, byte[][] a, int count, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            int  nread    = 0;
            bool recvmore = true;

            for (int i = 0; recvmore && i < count; ++i)
            {
                // Cheat! We never close any msg
                // because we want to steal the buffer.
                Msg msg = RecvMsg(s, flags);
                if (msg == null)
                {
                    nread = -1;
                    break;
                }

                // Cheat: acquire zmq_msg buffer.
                a[i] = msg.Data;

                // Assume zmq_socket ZMQ_RVCMORE is properly set.
                recvmore = msg.HasMore;
            }
            return(nread);
        }
예제 #2
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
 public static bool Connect(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw new InvalidOperationException();
     }
     return s.Connect(addr);
 }
예제 #3
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
 public static void Close(SocketBase s)
 {
     if (s == null || !s.CheckTag())
     {
         throw new InvalidOperationException();
     }
     s.Close();
 }
예제 #4
0
 public static void Close(SocketBase s)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     s.Close();
 }
예제 #5
0
 public static bool Unbind(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     return(s.TermEndpoint(addr));
 }
예제 #6
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
 public static void Close(SocketBase s)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     s.Close();
 }
예제 #7
0
 public static void Disconnect(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     s.TermEndpoint(addr);
 }
예제 #8
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        public static void Connect(SocketBase s, String addr)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.Connect(addr);
        }
예제 #9
0
파일: ZMQ.cs 프로젝트: JayShelton/netmq
        public static int BindRandomPort(SocketBase s, String addr)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            return s.BindRandomPort(addr);
        }
예제 #10
0
        public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.SetSocketOption(option, optval);
        }
예제 #11
0
        public static Object GetSocketOptionX(SocketBase s, ZmqSocketOptions option)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            return(s.GetSocketOptionX(option));
        }
예제 #12
0
        public static void SocketMonitor(SocketBase s, String addr, SocketEvent events)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.Monitor(addr, events);
        }
예제 #13
0
        public static void Bind(SocketBase s, String addr)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.Bind(addr);
        }
예제 #14
0
        public static int BindRandomPort(SocketBase s, String addr)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            return(s.BindRandomPort(addr));
        }
예제 #15
0
        public static void Send(SocketBase s, byte[] buf, int len, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            Msg msg = new Msg(len);

            msg.Put(buf, 0, len);

            SendMsg(s, msg, flags);
        }
예제 #16
0
        // Send multiple messages.
        //
        // If flag bit ZMQ_SNDMORE is set the vector is treated as
        // a single multi-part message, i.e. the last message has
        // ZMQ_SNDMORE bit switched off.
        //
        public void SendIOv(SocketBase s, byte[][] a, int count, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }
            Msg msg;

            for (int i = 0; i < count; ++i)
            {
                msg = new Msg(a[i]);
                if (i == count - 1)
                {
                    flags = flags & ~SendReceiveOptions.SendMore;
                }
                SendMsg(s, msg, flags);
            }
        }
예제 #17
0
        // Receiving functions.

        public static Msg Recv(SocketBase s, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }
            Msg msg = RecvMsg(s, flags);

            if (msg == null)
            {
                return(null);
            }

            //  At the moment an oversized message is silently truncated.
            //  TODO: Build in a notification mechanism to report the overflows.
            //int to_copy = nbytes < len_ ? nbytes : len_;

            return(msg);
        }
예제 #18
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        public static void Send(SocketBase s, byte[] buf, int len, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            Msg msg = new Msg(len);
            msg.Put(buf, 0, len);

            SendMsg(s, msg, flags);
        }
예제 #19
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
        public static Object GetSocketOptionX(SocketBase s, ZmqSocketOptions option)
        {
            if (s == null || !s.CheckTag())
            {
                throw new InvalidOperationException();
            }

            return s.GetSocketOptionX(option);
        }
예제 #20
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
        public static int Send(SocketBase s, byte[] buf, int len, SendRecieveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw new InvalidOperationException();
            }

            Msg msg = new Msg(len);
            msg.Put(buf, 0, len);

            int rc = SendMsg(s, msg, flags);
            if (rc < 0)
            {
                return -1;
            }

            return rc;
        }
예제 #21
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
        public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
        {
            if (s == null || !s.CheckTag())
            {
                throw new InvalidOperationException();
            }

            s.SetSocketOption(option, optval);
        }
예제 #22
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
        public static bool SocketMonitor(SocketBase s, String addr, SocketEvent events)
        {
            if (s == null || !s.CheckTag())
            {
                throw new InvalidOperationException();
            }

            return s.Monitor(addr, events);
        }
예제 #23
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
 public static bool Unbind(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw new InvalidOperationException();
     }
     return s.TermEndpoint(addr);
 }
예제 #24
0
파일: ZMQ.cs 프로젝트: oskarwkarlsson/netmq
        // Send multiple messages.
        //
        // If flag bit ZMQ_SNDMORE is set the vector is treated as
        // a single multi-part message, i.e. the last message has
        // ZMQ_SNDMORE bit switched off.
        //
        public int SendIOv(SocketBase s, byte[][] a, int count, SendRecieveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw new InvalidOperationException();
            }
            int rc = 0;
            Msg msg;

            for (int i = 0; i < count; ++i)
            {
                msg = new Msg(a[i]);
                if (i == count - 1)
                    flags = flags & ~SendRecieveOptions.SendMore;
                rc = SendMsg(s, msg, flags);
                if (rc < 0)
                {
                    rc = -1;
                    break;
                }
            }
            return rc;
        }
예제 #25
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        public static Object GetSocketOptionX(SocketBase s, ZmqSocketOptions option)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            return s.GetSocketOptionX(option);
        }
예제 #26
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        // Receiving functions.
        public static Msg Recv(SocketBase s, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }
            Msg msg = RecvMsg(s, flags);
            if (msg == null)
            {
                return null;
            }

            //  At the moment an oversized message is silently truncated.
            //  TODO: Build in a notification mechanism to report the overflows.
            //int to_copy = nbytes < len_ ? nbytes : len_;

            return msg;
        }
예제 #27
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        // Send multiple messages.
        //
        // If flag bit ZMQ_SNDMORE is set the vector is treated as
        // a single multi-part message, i.e. the last message has
        // ZMQ_SNDMORE bit switched off.
        //
        public void SendIOv(SocketBase s, byte[][] a, int count, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }
            Msg msg;

            for (int i = 0; i < count; ++i)
            {
                msg = new Msg(a[i]);
                if (i == count - 1)
                    flags = flags & ~SendReceiveOptions.SendMore;
                SendMsg(s, msg, flags);

            }
        }
예제 #28
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        // Receive a multi-part message
        //
        // Receives up to *count_ parts of a multi-part message.
        // Sets *count_ to the actual number of parts read.
        // ZMQ_RCVMORE is set to indicate if a complete multi-part message was read.
        // Returns number of message parts read, or -1 on error.
        //
        // Note: even if -1 is returned, some parts of the message
        // may have been read. Therefore the client must consult
        // *count_ to retrieve message parts successfully read,
        // even if -1 is returned.
        //
        // The iov_base* buffers of each iovec *a_ filled in by this
        // function may be freed using free().
        //
        // Implementation note: We assume zmq::msg_t buffer allocated
        // by zmq::recvmsg can be freed by free().
        // We assume it is safe to steal these buffers by simply
        // not closing the zmq::msg_t.
        //
        public int RecvIOv(SocketBase s, byte[][] a, int count, SendReceiveOptions flags)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            int nread = 0;
            bool recvmore = true;

            for (int i = 0; recvmore && i < count; ++i)
            {
                // Cheat! We never close any msg
                // because we want to steal the buffer.
                Msg msg = RecvMsg(s, flags);
                if (msg == null)
                {
                    nread = -1;
                    break;
                }

                // Cheat: acquire zmq_msg buffer.
                a[i] = msg.Data;

                // Assume zmq_socket ZMQ_RVCMORE is properly set.
                recvmore = msg.HasMore;
            }
            return nread;
        }
예제 #29
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
 public static bool Unbind(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     return s.TermEndpoint(addr);
 }
예제 #30
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        public static void SocketMonitor(SocketBase s, String addr, SocketEvent events)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.Monitor(addr, events);
        }
예제 #31
0
파일: ZMQ.cs 프로젝트: kamlesh-patel/netmq
        public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.SetSocketOption(option, optval);
        }