static string ReadMessage(SslStream sslStream)
{
// Read the message sent by the client.
// The client signals the end of the message using the
// "" marker.
StringBuilder messageData = new StringBuilder();
int bytes = -1;
do
{
// Read the client's test message.
bytes = sslStream.ReadByte();
// Use Decoder class to convert from bytes to UTF8
// in case a character spans two buffers.
Decoder decoder = Encoding.UTF8.GetDecoder();
char znak = (char)bytes;
messageData.Append(znak);
// Check for EOF or an empty message.
if (messageData.ToString().IndexOf("") != -1)
{
break;
}
} while (bytes != 0);
return messageData.ToString();
}