@@ -204,16 +204,14 @@ public async Task Server_ClientDisconnects_CallCanceled()
204
204
{
205
205
// Note: System.Net.Sockets does not RST the connection by default, it just FINs.
206
206
// Http.Sys's disconnect notice requires a RST.
207
- using ( Socket socket = await SendHungRequestAsync ( "GET" , address ) )
207
+ using ( var client = await SendHungRequestAsync ( "GET" , address ) )
208
208
{
209
209
Assert . True ( received . WaitOne ( interval ) , "Receive Timeout" ) ;
210
210
211
211
// Force a RST
212
- socket . LingerState = new LingerOption ( true , 0 ) ;
213
- socket . Dispose ( ) ;
214
-
215
- aborted . Set ( ) ;
212
+ client . LingerState = new LingerOption ( true , 0 ) ;
216
213
}
214
+ aborted . Set ( ) ;
217
215
Assert . True ( canceled . WaitOne ( interval ) , "canceled" ) ;
218
216
}
219
217
}
@@ -240,10 +238,10 @@ public async Task Server_Abort_CallCanceled()
240
238
return Task . FromResult ( 0 ) ;
241
239
} ) )
242
240
{
243
- using ( Socket socket = await SendHungRequestAsync ( "GET" , address ) )
241
+ using ( var client = await SendHungRequestAsync ( "GET" , address ) )
244
242
{
245
243
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 ) ) ;
247
245
}
248
246
}
249
247
}
@@ -287,7 +285,7 @@ private async Task<string> SendRequestAsync(string uri, string upload)
287
285
}
288
286
}
289
287
290
- private async Task < Socket > SendHungRequestAsync ( string method , string address )
288
+ private async Task < TcpClient > SendHungRequestAsync ( string method , string address )
291
289
{
292
290
// Connect with a socket
293
291
Uri uri = new Uri ( address ) ;
@@ -302,8 +300,7 @@ private async Task<Socket> SendHungRequestAsync(string method, string address)
302
300
byte [ ] requestBytes = BuildGetRequest ( method , uri ) ;
303
301
await stream . WriteAsync ( requestBytes , 0 , requestBytes . Length ) ;
304
302
305
- // Return the opaque network stream
306
- return client . Client ;
303
+ return client ;
307
304
}
308
305
catch ( Exception )
309
306
{
0 commit comments