当前位置: 首页>>代码示例>>C#>>正文


C# zmq.SocketBase类代码示例

本文整理汇总了C#中NetMQ.zmq.SocketBase的典型用法代码示例。如果您正苦于以下问题:C# SocketBase类的具体用法?C# SocketBase怎么用?C# SocketBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SocketBase类属于NetMQ.zmq命名空间,在下文中一共展示了SocketBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PgmListener

        public PgmListener(IOThread ioThread, SocketBase socket, Options options)
            : base(ioThread, options)
        {
            m_socket = socket;

            m_ioObject = new IOObject(ioThread);
        }
开发者ID:bubbafat,项目名称:netmq,代码行数:7,代码来源:PgmListener.cs

示例2: SessionBase

        public SessionBase(IOThread ioThread, bool connect,
                                             SocketBase socket, Options options, Address addr)
            : base(ioThread, options)
        {
            m_ioObject = new IOObject(ioThread);

            m_connect = connect;
            m_pipe = null;
            m_incompleteIn = false;
            m_pending = false;
            m_engine = null;
            m_socket = socket;
            m_ioThread = ioThread;
            m_hasLingerTimer = false;
            m_identitySent = false;
            m_identityReceived = false;
            m_addr = addr;

            if (options.RawSocket)
            {
                m_identitySent = true;
                m_identityReceived = true;
            }

            m_terminatingPipes = new HashSet<Pipe>();
        }
开发者ID:JayShelton,项目名称:netmq,代码行数:26,代码来源:SessionBase.cs

示例3: Read

        public static MonitorEvent Read(SocketBase s)
        {
            Msg msg = s.Recv(0);
            if (msg == null)
                return null;

            int pos = 0;
            ByteArraySegment data = msg.Data;

            SocketEvent @event =(SocketEvent) data.GetInteger(pos);
            pos += 4;
            int len = (int)data[pos++];
            string addr = data.GetString(len, pos);
            pos += len;
            int flag = (int)data[pos++];
            Object arg = null;

            if (flag == ValueInteger)
            {
                arg = data.GetInteger(pos);
            }
            else if (flag == ValueChannel)
            {
                if (SizeOfIntPtr == 4)
                {
                    arg = new IntPtr(data.GetInteger(pos));
                }
                else
                {
                    arg = new IntPtr(data.GetLong(pos));
                }
            }

            return new MonitorEvent(@event, addr, arg);
        }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:35,代码来源:MonitorEvent.cs

示例4: Close

 public static void Close(SocketBase s)
 {
     if (s == null || !s.CheckTag())
     {
         throw new InvalidOperationException();
     }
     s.Close();
 }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:8,代码来源:ZMQ.cs

示例5: Close

 public static void Close(SocketBase s)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     s.Close();
 }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:8,代码来源:ZMQ.cs

示例6: Connect

 public static bool Connect(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw new InvalidOperationException();
     }
     return s.Connect(addr);
 }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:8,代码来源:ZMQ.cs

示例7: TcpListener

 public TcpListener(IOThread ioThread, SocketBase socket, Options options)
     : base(ioThread, options)
 {
     m_ioObject = new IOObject(ioThread);
     m_address = new TcpAddress();
     m_handle = null;
     m_socket = socket;
 }
开发者ID:hecwow,项目名称:netmq,代码行数:8,代码来源:TcpListener.cs

示例8: BindRandomPort

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

            return s.BindRandomPort(addr);
        }
开发者ID:JayShelton,项目名称:netmq,代码行数:9,代码来源:ZMQ.cs

示例9: Connect

        public static void Connect(SocketBase s, String addr)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.Connect(addr);
        }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:9,代码来源:ZMQ.cs

示例10: Read

        public static MonitorEvent Read(SocketBase s)
        {
            Msg msg = s.Recv(0);
            if (msg == null)
                return null;

            int pos = 0;
            ByteArraySegment data = msg.Data;

            SocketEvent @event = (SocketEvent)data.GetInteger(Endianness.Little, pos);
            pos += 4;
            int len = (int)data[pos++];
            string addr = data.GetString(len, pos);
            pos += len;
            int flag = (int)data[pos++];
            Object arg = null;

            if (flag == ValueInteger)
            {
                arg = data.GetInteger(Endianness.Little, pos);
            }
            else if (flag == ValueChannel)
            {
                IntPtr value;

                if (SizeOfIntPtr == 4)
                {
                    value = new IntPtr(data.GetInteger(Endianness.Little, pos));
                }
                else
                {
                    value = new IntPtr(data.GetLong(Endianness.Little, pos));
                }

                GCHandle handle = GCHandle.FromIntPtr(value);
                Socket socket = null;

                if (handle.IsAllocated)
                {
                    socket = handle.Target as Socket;
                }

                handle.Free();

                arg = socket;
            }

            return new MonitorEvent(@event, addr, arg);
        }
开发者ID:GianniBortoloBossini,项目名称:netmq,代码行数:49,代码来源:MonitorEvent.cs

示例11: RecvMsg

 public static Msg RecvMsg(SocketBase s, SendReceiveOptions flags)
 {
     return s.Recv(flags);
 }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:4,代码来源:ZMQ.cs

示例12: SendIOv

        // 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);

            }
        }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:23,代码来源:ZMQ.cs

示例13: SendMsg

 private static void SendMsg(SocketBase s, Msg msg, SendReceiveOptions flags)
 {
     s.Send(msg, flags);
 }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:4,代码来源:ZMQ.cs

示例14: Unbind

 public static bool Unbind(SocketBase s, String addr)
 {
     if (s == null || !s.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     return s.TermEndpoint(addr);
 }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:8,代码来源:ZMQ.cs

示例15: RecvIOv

        // 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;
        }
开发者ID:kamlesh-patel,项目名称:netmq,代码行数:49,代码来源:ZMQ.cs


注:本文中的NetMQ.zmq.SocketBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。