NetMQ.Poller.RemovePollInSocket C# (CSharp) 메소드

RemovePollInSocket() 공개 메소드

Delete the given socket from this Poller's collection of socket/actions.
socket must not be null. This poller must not have already been disposed.
public RemovePollInSocket ( [ socket ) : void
socket [ the Socket to remove
리턴 void
        public void RemovePollInSocket([NotNull] Socket socket)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

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

            m_pollinSockets.Remove(socket);

            m_isDirty = true;
        }

Usage Example

예제 #1
0
            private void Configure([NotNull] string interfaceName, int port)
            {
                // In case the beacon was configured twice
                if (m_udpSocket != null)
                {
                    m_poller.RemovePollInSocket(m_udpSocket);
                    m_udpSocket.Close();
                }

                m_udpPort   = port;
                m_udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                m_poller.AddPollInSocket(m_udpSocket, OnUdpReady);

                // Ask operating system for broadcast permissions on socket
                m_udpSocket.EnableBroadcast = true;

                // Allow multiple owners to bind to socket; incoming
                // messages will replicate to each owner
                m_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

                IPAddress bindTo = null;
                IPAddress sendTo = null;

                if (interfaceName == "*")
                {
                    bindTo = IPAddress.Any;
                    sendTo = IPAddress.Broadcast;
                }
                else
                {
                    var interfaceCollection = new InterfaceCollection();

                    var interfaceAddress = !string.IsNullOrEmpty(interfaceName)
                        ? IPAddress.Parse(interfaceName)
                        : null;

                    foreach (var @interface in interfaceCollection)
                    {
                        if (interfaceAddress == null || @interface.Address.Equals(interfaceAddress))
                        {
                            sendTo = @interface.BroadcastAddress;
                            bindTo = @interface.Address;
                            break;
                        }
                    }
                }

                if (bindTo != null)
                {
                    m_broadcastAddress = new IPEndPoint(sendTo, m_udpPort);
                    m_udpSocket.Bind(new IPEndPoint(bindTo, m_udpPort));

                    string hostname = "";

                    try
                    {
                        if (!IPAddress.Any.Equals(bindTo) && !IPAddress.IPv6Any.Equals(bindTo))
                        {
                            var host = Dns.GetHostEntry(bindTo);
                            hostname = host != null ? host.HostName : "";
                        }
                    }
                    catch (Exception)
                    {}

                    m_pipe.Send(hostname);
                }
            }