@@ -254,9 +254,12 @@ public int ReadByte()
254
254
{
255
255
return _inputStream . ReadByte ( ) ;
256
256
}
257
- catch ( IOException )
257
+ catch ( Exception ex )
258
258
{
259
- _isAlive = false ;
259
+ if ( ex is IOException || ex is SocketException )
260
+ {
261
+ _isAlive = false ;
262
+ }
260
263
261
264
throw ;
262
265
}
@@ -270,9 +273,12 @@ public int ReadByteAsync()
270
273
{
271
274
return _inputStream . ReadByte ( ) ;
272
275
}
273
- catch ( IOException )
276
+ catch ( Exception ex )
274
277
{
275
- _isAlive = false ;
278
+ if ( ex is IOException || ex is SocketException )
279
+ {
280
+ _isAlive = false ;
281
+ }
276
282
throw ;
277
283
}
278
284
}
@@ -296,9 +302,13 @@ public async Task ReadAsync(byte[] buffer, int offset, int count)
296
302
offset += currentRead ;
297
303
shouldRead -= currentRead ;
298
304
}
299
- catch ( IOException )
305
+ catch ( Exception ex )
300
306
{
301
- _isAlive = false ;
307
+ if ( ex is IOException || ex is SocketException )
308
+ {
309
+ _isAlive = false ;
310
+ }
311
+
302
312
throw ;
303
313
}
304
314
}
@@ -330,9 +340,12 @@ public void Read(byte[] buffer, int offset, int count)
330
340
offset += currentRead ;
331
341
shouldRead -= currentRead ;
332
342
}
333
- catch ( IOException )
343
+ catch ( Exception ex )
334
344
{
335
- _isAlive = false ;
345
+ if ( ex is IOException || ex is SocketException )
346
+ {
347
+ _isAlive = false ;
348
+ }
336
349
throw ;
337
350
}
338
351
}
@@ -369,9 +382,13 @@ public void Write(IList<ArraySegment<byte>> buffers)
369
382
ThrowHelper . ThrowSocketWriteError ( _endpoint , status ) ;
370
383
}
371
384
}
372
- catch ( IOException )
385
+ catch ( Exception ex )
373
386
{
374
- _isAlive = false ;
387
+ if ( ex is IOException || ex is SocketException )
388
+ {
389
+ _isAlive = false ;
390
+ }
391
+ _logger . LogError ( ex , nameof ( PooledSocket . Write ) ) ;
375
392
throw ;
376
393
}
377
394
}
@@ -390,9 +407,12 @@ public async Task WriteAsync(IList<ArraySegment<byte>> buffers)
390
407
ThrowHelper . ThrowSocketWriteError ( _endpoint ) ;
391
408
}
392
409
}
393
- catch ( IOException ex )
410
+ catch ( Exception ex )
394
411
{
395
- _isAlive = false ;
412
+ if ( ex is IOException || ex is SocketException )
413
+ {
414
+ _isAlive = false ;
415
+ }
396
416
_logger . LogError ( ex , nameof ( PooledSocket . WriteAsync ) ) ;
397
417
throw ;
398
418
}
0 commit comments