NetMQ.Poller.AddPollInSocket C# (CSharp) Метод

AddPollInSocket() публичный Метод

Add the given socket and Action to this Poller's collection of socket/actions.
socket and callback must not be null. The socket must not have already been added to this poller. This poller must not have already been disposed.
public AddPollInSocket ( [ socket, [ callback ) : void
socket [ the Socket to add
callback [ the Action to add
Результат void
        public void AddPollInSocket([NotNull] Socket socket, [NotNull] Action<Socket> callback)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (m_pollinSockets.ContainsKey(socket))
            {
                throw new ArgumentException("Socket already added to poller");
            }

            if (m_disposed)
            {
                throw new ObjectDisposedException("Poller is disposed");
            }

            m_pollinSockets.Add(socket, callback);

            m_isDirty = true;
        }

Usage Example

Пример #1
0
        static void Main(string[] args)
        {
            using (var context = NetMQContext.Create())
            using (var udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
            using (var poller = new Poller())
            {
                // Ask OS to let us do broadcasts from socket
                udpSocket.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.Broadcast, 1);

                // Bind UDP socket to local port so we can receive pings
                udpSocket.Bind(new IPEndPoint(IPAddress.Any, PingPortNumber));

                // We use zmq_poll to wait for activity on the UDP socket, because
                // this function works on non-0MQ file handles. We send a beacon
                // once a second, and we collect and report beacons that come in
                // from other nodes:

                poller.AddPollInSocket(udpSocket, socket => { });
                poller.PollTillCancelledNonBlocking();
                //poller.ad
                //var poller = new z
                //var pollItemsList = new List<ZPollItem>();
                //pollItemsList.Add(new ZPollItem(ZPoll.In));
                //var pollItem = ZPollItem.CreateReceiver();
                //ZMessage message;
                //ZError error;
                //pollItem.ReceiveMessage(udpSocket, out message, out error);
                //pollItem.ReceiveMessage = (ZSocket socket, out ZMessage message, out ZError error) =>

                // Send first ping right away

            }
        }
All Usage Examples Of NetMQ.Poller::AddPollInSocket