SafeSslStream |
The purpose of this class is to wrap SslStream and provide thread-safe Read and Write blocking operations. The reason this is necessary is because NetworkStream is thread-safe for simultaneous reads and writes as long as there is a single reader and a single writer. SslStream, on the other hand, does not guarantee this safety. However, we can use BeginRead/BeginWrite to do asynchronous operations and simply signal to the main thread that they've completed. Performance will suffer slightly, but TLS network performance incurs its own buffering penalties by nature. |