public void ConnectAsyncIPV6CallbackTest() { ManualResetEventSlim mevent = new ManualResetEventSlim(false); mevent.Reset(); try { ipv6Protocol.Listen(); UdpProtocol ipvClient = this.CreateIPV6ClientProtocol(ipv6ServerAddress); ISocket udpSocket = null; ipvClient.ConnectAsync((socket) => { udpSocket = socket; mevent.Set(); }, ipv6ServerAddress, PORT); Assert.IsTrue(mevent.Wait(10000), "Connection never triggered callback."); sockets.Add(udpSocket); Assert.IsNotNull(udpSocket, "Callback did not receive a socket."); Assert.IsTrue(udpSocket.Connected, "A connection could not be established."); udpSocket.Disconnect(); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public async Task ConnectAsyncIPV6TaskTest() { try { ipv6Protocol.Listen(); UdpProtocol ipvClient = this.CreateIPV6ClientProtocol(ipv6ServerAddress); var udpSocket = await ipvClient.ConnectAsync(ipv6ServerAddress, PORT); sockets.Add(udpSocket); Assert.IsNotNull(udpSocket, "The udpSocket instance was null."); Assert.IsTrue(udpSocket.Connected, "A connection could not be established."); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }