コード例 #1
0
        public void UdpProxyServer_should_bind_to_ephemeral_port()
        {
            var server =
                new ServerBootstrap().SetTransport(TransportType.Udp).Build().NewReactor(NodeBuilder.BuildNode().Host(IPAddress.Any).WithPort(0));

            server.Start();
            Assert.AreNotEqual(0, server.LocalEndpoint.Port);
            server.Stop();
        }
コード例 #2
0
        public void UdpConnection_should_bind_to_outbound_ephemeral_port()
        {
            var serverAddress = NodeBuilder.BuildNode().Host(IPAddress.Loopback).WithPort(13171);
            var server        =
                new ServerBootstrap().SetTransport(TransportType.Udp).Build().NewReactor(serverAddress);
            var connection = new ClientBootstrap().SetTransport(TransportType.Udp)
                             .Build()
                             .NewConnection(Node.Loopback(), serverAddress);

            server.Start();
            connection.Open();
            Assert.NotEqual(0, connection.Local.Port);
            connection.Close();
            server.Stop();
        }