public async Task ShouldBeAbleToConnectAgainIfFirstFailed() { var socketSettings = new SocketSettings { ConnectionTimeout = TimeSpan.FromSeconds(10), HostResolver = new SystemHostResolver(), EncryptionManager = new EncryptionManager(false, null) }; var client = new TcpSocketClient(socketSettings); // We fail to connect the first time as there is no server to connect to // ReSharper disable once PossibleNullReferenceException var exception = await Record.ExceptionAsync( async() => await client.ConnectSocketAsync(IPAddress.Parse("127.0.0.1"), 54321)); // start a server on port 20003 var serverSocket = new TcpListener(new IPEndPoint(IPAddress.Loopback, 54321)); try { serverSocket.Start(); // We should not get any error this time as server in online now. await client.ConnectSocketAsync(IPAddress.Parse("127.0.0.1"), 54321); } finally { serverSocket.Stop(); } }
public async Task ShouldBeAbleToConnectAgainIfFirstFailed() { var socketSettings = new SocketSettings { ConnectionTimeout = TimeSpan.FromSeconds(10) }; var client = new TcpSocketClient(socketSettings); // We fail to connect the first time as there is no server to connect to var exception = await Record.ExceptionAsync( async() => await client.ConnectSocketAsync(IPAddress.Parse("127.0.0.1"), 20003)); // start a server on port 20003 var serverSocket = new TcpListener(new IPEndPoint(IPAddress.Loopback, 20003)); try { serverSocket.Start(); // We should not get any error this time as server in online now. await client.ConnectSocketAsync(IPAddress.Parse("127.0.0.1"), 20003); } finally { serverSocket.Stop(); } }