Skip to content

Commit

Permalink
Fix the IOCP count config var test
Browse files Browse the repository at this point in the history
Fixed to use any available port instead of a specific port.

Fixes dotnet#106206
  • Loading branch information
kouvel committed Aug 14, 2024
1 parent abdef75 commit 919f060
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1394,15 +1394,14 @@ static async Task RunAsyncIOTest()
var done = new AutoResetEvent(false);

// Receiver
var receiveBuffer = new byte[1];
using var listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
var t = ThreadTestHelpers.CreateGuardedThread(
out Action checkForThreadErrors,
out Action waitForThread,
async () =>
{
using var listener = new TcpListener(IPAddress.Loopback, 55555);
var receiveBuffer = new byte[1];
listener.Start();
done.Set(); // indicate listener started
while (true)
{
// Accept a connection, receive a byte
Expand All @@ -1415,15 +1414,14 @@ static async Task RunAsyncIOTest()
});
t.IsBackground = true;
t.Start();
done.CheckedWait(); // wait for listener to start

// Sender
var sendBuffer = new byte[1];
for (int i = 0; i < PretendProcessorCount / 2; i++)
{
// Connect, send a byte
using var client = new TcpClient();
await client.ConnectAsync(IPAddress.Loopback, 55555);
await client.ConnectAsync((IPEndPoint)listener.LocalEndpoint);
int bytesSent =
await client.Client.SendAsync(new ArraySegment<byte>(sendBuffer), SocketFlags.None);
Assert.Equal(1, bytesSent);
Expand Down

0 comments on commit 919f060

Please sign in to comment.