You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using HttpClientStudy.Core.Utilities;
|
|
|
|
namespace HttpClientStudy.UnitTest
|
|
{
|
|
/// <summary>
|
|
/// 临时测试
|
|
/// </summary>
|
|
public class TempTest
|
|
{
|
|
private readonly ITestOutputHelper _output;
|
|
public TempTest(ITestOutputHelper output)
|
|
{
|
|
_output = output;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task TestAsync()
|
|
{
|
|
var ips = await Dns.GetHostAddressesAsync("www.hao123.com");
|
|
string firstIp = ips.FirstOrDefault().ToString();
|
|
|
|
//自定义行为
|
|
var socketsHandler = new SocketsHttpHandler
|
|
{
|
|
PooledConnectionLifetime = TimeSpan.FromSeconds(1),
|
|
PooledConnectionIdleTimeout = TimeSpan.FromSeconds(1),
|
|
MaxConnectionsPerServer = 10
|
|
};
|
|
|
|
var client = new HttpClient(socketsHandler);
|
|
|
|
for (var i = 0; i < 3; i++)
|
|
{
|
|
if (i > 0)
|
|
{
|
|
await Task.Delay(2000);
|
|
}
|
|
await client.GetAsync("https://www.hao123.com");
|
|
}
|
|
|
|
var queryNetwork = CmdUtility.RunCmd($"netstat -ano | findstr {firstIp}");
|
|
|
|
_output.WriteLine(queryNetwork);
|
|
}
|
|
}
|
|
}
|