diff --git a/src/ZeroMQ/Poller.cs b/src/ZeroMQ/Poller.cs index dda3001..621704d 100644 --- a/src/ZeroMQ/Poller.cs +++ b/src/ZeroMQ/Poller.cs @@ -123,6 +123,47 @@ public void ClearSockets() CreatePollItems(); } + /// + /// Remove a socket that is polled for input/output events, depending on its capabilities. + /// + /// The to remove. + /// is null. + /// has no event handlers. + public void RemoveSocket(ZmqSocket socket) + { + if (socket == null) + { + throw new ArgumentNullException("socket"); + } + + var pollEvents = socket.GetPollEvents(); + + if (pollEvents == PollEvents.None) + { + throw new ArgumentOutOfRangeException("socket", "Unable to remove socket without at least one handler."); + } + + _pollableSockets.Remove(new PollItem(socket.SocketHandle, pollEvents)); + CreatePollItems(); + } + + /// + /// Remove a collection of sockets that is polled for input/output events, depending on their capabilities. + /// + /// The collection of s to poll. + public void RemoveSockets(IEnumerable sockets) + { + if (sockets == null) + { + throw new ArgumentNullException("sockets"); + } + + foreach (var socket in sockets) + { + RemoveSocket(socket); + } + } + /// /// Multiplex input/output events over the contained set of sockets in blocking mode, firing /// or as appropriate.