0

Guys i'm trying to use SSLStream to test my app and so far it goes well (the client/server auth successfully), but the problem i have is reading:

How to know whether or not i have reached the end?

Microsoft's example with "EOF" simply does not work and i have tried "\r\n\r" comparison, but sometimes with long responses, it cuts out and thus i can only get a portion of the information. How can i read from this stream without knowing how long is the stream itself?

I've also tried comparing the last position of the stream with a variable that keeps the last position of the last loop and this does not work too (when you try to Read, but you've reached the end you get IOException).

Anonymous
  • 748
  • 3
  • 10
  • 22

1 Answers1

0

When there is no more data to be read from the stream, SSLStream.Read will return zero.

See: http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.read(v=vs.110).aspx

William
  • 1,867
  • 11
  • 10
  • That's not happening in my case. I get IOException if i don't break out of the reading loop. I really don't understand what's the problem. I authenticate to my client, the client sends data and fails to read it unless i break. – Anonymous Nov 12 '13 at 20:43
  • Are you in control of both ends of the connection and what IOException are you getting exactly? – William Nov 13 '13 at 05:41
  • Yeah, i ended up doing a really nasty way - i'm waiting for the exception to kick in, to know that there is no more content in the stream. Coupled with timeout tweaking, works kinda good, but its a really nasty way to read from the stream. I think MS have to improve SSLStream a lot more, to be used in production environment. – Anonymous Nov 16 '13 at 14:15