【发布时间】:2015-09-08 02:24:44
【问题描述】:
假设_sslStream 是在客户端建立的SslStream 连接。
private void DoStuff(string message)
{
_streamWriter = new StreamWriter(_sslStream) { AutoFlush = true };
_streamWriter.Write(GetGzipBytes("hello world"));
}
private static byte[] GetGzipBytes(string message)
{
//Not a final implementation. Cannot add string "<EOF>" mark
return Encoding.UTF8.GetBytes(message);
}
如何在服务器端检测接收到的字节是否完整?
是否有一些推荐的“字节数组结束”标记我应该添加到数组的末尾?
我如何确保GetGzipBytes() 方法不会产生byte[] 会在消息中包含这些字节?
如果是字符串,我会调用:
_streamReader.ReadLine();
【问题讨论】: