public static string ReceiveString([NotNull] this NetMQSocket socket, [NotNull] Encoding encoding, TimeSpan timeout)
        {
            var result = socket.Poll(PollEvents.PollIn, timeout);

            if (!result.HasFlag(PollEvents.PollIn))
            {
                return(null);
            }

            var msg = socket.ReceiveString(encoding);

            return(msg);
        }
        public static string ReceiveString(this NetMQSocket socket, TimeSpan timeout)
        {
            var item  = new PollItem(socket.SocketHandle, PollEvents.PollIn);
            var items = new[] { item };

            ZMQ.Poll(items, (int)timeout.TotalMilliseconds);

            if (item.ResultEvent.HasFlag(PollEvents.PollError) && !socket.IgnoreErrors)
            {
                throw new ErrorPollingException("Error while polling", socket);
            }

            if (!item.ResultEvent.HasFlag(PollEvents.PollIn))
            {
                return(null);
            }

            var msg = socket.ReceiveString();

            return(msg);
        }