private static void Main(string[] args) { Console.WriteLine("We're going to write a ton of data to the console. 100k iterations."); Console.WriteLine("Going!"); var remote = Node.Loopback(11010); var client = new ClientBootstrap().SetTransport(TransportType.Udp) .SetEncoder(new NoOpEncoder()) .SetDecoder(new NoOpDecoder()).Build().NewConnection(Node.Any(), remote); client.Open(); var bytes = Encoding.UTF8.GetBytes("THIS IS OUR TEST PAYLOAD"); var stopwatch = Stopwatch.StartNew(); var i = 0; while (i < 100000) { client.Send(bytes, 0, bytes.Length, remote); i++; } Console.WriteLine("Done queuing messages... waiting for queue to drain"); while (client.MessagesInSendQueue > 0) { Thread.Sleep(10); } Console.WriteLine("Done, press any key to exit"); stopwatch.Stop(); Console.WriteLine("Took {0} seconds to complete", stopwatch.Elapsed.TotalSeconds); Console.ReadKey(); }
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(); }