I've got a server that uses a Socket with SslStream like this:
Socket senderSocket;
NetworkStream nStream = new NetworkStream(senderSocket, true);
SslStream ssStream = new SslStream(nStream);
I use the SslStream's synchronous Write and async BeginRead method. Before, I used the BeginWrite method instead of Write, and sometimes got an exception like this:
NotSupportedException: The BeginWrite method cannot be called when another write operation is pending
I guess this was thrown because my client has a Ping method.
Should I lock the Write method on my server? If so, should I lock the Socket or use Stream.Synchronized for SslStream?
Thank you