I'm facing a strange error. Following code is always throwing exception (System.ArgumentException "Stream was not writable
"):
TcpClient socket = new TcpClient();
socket.Connect("serverIp", serverPort);
//wrap networkstream with ssl
SslStream sslStream = new SslStream(socket.GetStream(),false);
stream.ReadTimeout = 5000;
stream.WriteTimeout = 5000;
//following line throws System.ArgumentException "Stream was not writable"
var writer = new BinaryWriter(sslStream);
writer.Write(abMessage, nStart, nLength);
writer.Flush();
'sslStream
' object canWrite
and canRead
properties are always 'false
'.
Obviously, I have Googled, and searched in many forums, but, I always found that same code which is not working for me.
How can I fix this exception?