Search code examples
c#socketsnetworkstreamsslstreamdisconnection

Detecting SslStream socket disconnection


I am using SslStream on top of NetworkStream that wraps a Socket, how could i detect Socket disconnection at this situation.

In another words i want to detect if the remote client closed the connection.


Solution

  • You will get an EOS when reading, or an IOException when writing.