public async Task Listen() { var udp = new Udp(); var cs = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var connected = false; MultiAddress listenerAddress = null; Action <Stream, MultiAddress, MultiAddress> handler = (stream, local, remote) => { Assert.IsNotNull(stream); connected = true; }; try { listenerAddress = udp.Listen("/ip4/127.0.0.1", handler, cs.Token); Assert.IsTrue(listenerAddress.Protocols.Any(p => p.Name == "udp")); using (var stream = await udp.ConnectAsync(listenerAddress, cs.Token)) { await Task.Delay(50); Assert.IsNotNull(stream); Assert.IsTrue(connected); } } finally { cs.Cancel(); } }
public HelloServer() { var udp = new Udp(); Address = udp.Listen("/ip4/127.0.0.1", Handler, cs.Token); }