public void ConnectOrBindAddress(NetMQSocket socket)
        {
            var port = socket.BindRandomPort(Uri.AbsoluteUri.TrimEnd('/'));
            var address = $"{Uri.Scheme}://{Uri.Host}:{port}";

            Uri = new Uri(address);
        }
        public void ConnectOrBindAddress(NetMQSocket socket)
        {
            var port    = socket.BindRandomPort(Uri.AbsoluteUri.TrimEnd('/'));
            var address = $"{Uri.Scheme}://{Uri.Host}:{port}";

            Uri = new Uri(address);
        }
Beispiel #3
0
        public int BindRandomPort(string host)
        {
            var address = $@"{DefaultProtocol}://{host}";
            var port    = Socket.BindRandomPort(address);

            EndPoints.Add($@"{address}:{port}");
            return(port);
        }
Beispiel #4
0
        public void BindRandom()
        {
            using (NetMQContext context = NetMQContext.Create())
            {
                using (NetMQSocket randomDealer = context.CreateDealerSocket())
                {
                    int port = randomDealer.BindRandomPort("tcp://*");

                    using (NetMQSocket connectingDealer = context.CreateDealerSocket())
                    {
                        connectingDealer.Connect("tcp://127.0.0.1:" + port);

                        randomDealer.Send("test");

                        Assert.AreEqual("test", connectingDealer.ReceiveString());
                    }
                }
            }
        }