Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit c79458a

Browse files
committed
React to changes in System.Net.Sockets.TcpClient.
1 parent fe9aa69 commit c79458a

File tree

1 file changed

+7
-10
lines changed
  • test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests

1 file changed

+7
-10
lines changed

test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/ServerTests.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,14 @@ public async Task Server_ClientDisconnects_CallCanceled()
204204
{
205205
// Note: System.Net.Sockets does not RST the connection by default, it just FINs.
206206
// Http.Sys's disconnect notice requires a RST.
207-
using (Socket socket = await SendHungRequestAsync("GET", address))
207+
using (var client = await SendHungRequestAsync("GET", address))
208208
{
209209
Assert.True(received.WaitOne(interval), "Receive Timeout");
210210

211211
// Force a RST
212-
socket.LingerState = new LingerOption(true, 0);
213-
socket.Dispose();
214-
215-
aborted.Set();
212+
client.LingerState = new LingerOption(true, 0);
216213
}
214+
aborted.Set();
217215
Assert.True(canceled.WaitOne(interval), "canceled");
218216
}
219217
}
@@ -240,10 +238,10 @@ public async Task Server_Abort_CallCanceled()
240238
return Task.FromResult(0);
241239
}))
242240
{
243-
using (Socket socket = await SendHungRequestAsync("GET", address))
241+
using (var client = await SendHungRequestAsync("GET", address))
244242
{
245243
Assert.True(received.WaitOne(interval), "Receive Timeout");
246-
Assert.Throws<SocketException>(() => socket.Receive(new byte[10]));
244+
Assert.Throws<IOException>(() => client.GetStream().Read(new byte[10], 0, 10));
247245
}
248246
}
249247
}
@@ -287,7 +285,7 @@ private async Task<string> SendRequestAsync(string uri, string upload)
287285
}
288286
}
289287

290-
private async Task<Socket> SendHungRequestAsync(string method, string address)
288+
private async Task<TcpClient> SendHungRequestAsync(string method, string address)
291289
{
292290
// Connect with a socket
293291
Uri uri = new Uri(address);
@@ -302,8 +300,7 @@ private async Task<Socket> SendHungRequestAsync(string method, string address)
302300
byte[] requestBytes = BuildGetRequest(method, uri);
303301
await stream.WriteAsync(requestBytes, 0, requestBytes.Length);
304302

305-
// Return the opaque network stream
306-
return client.Client;
303+
return client;
307304
}
308305
catch (Exception)
309306
{

0 commit comments

Comments
 (0)