标题:Tcp C# 数据过多造成数据丢失,求助
取消只看楼主
OTTseawind
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-8-5
结帖率:100%
已结贴  问题点数:20 回复次数:1 
Tcp C# 数据过多造成数据丢失,求助
if (!isFailed)
            {
                try
                {
                    byte[] buffer = new byte[1024 * 1024];
                    int totalLengh = 0;
                    do
                    {

                        int headLen = stream.Read(buffer, totalLengh, buffer.Length - totalLengh);
                        totalLengh += headLen;
                        if (totalLengh == buffer.Length)
                        {
                          string datagram = Encoding.UTF8.GetString(buffer, 0, totalLengh);  
                        }
                        if (headLen == 0)
                        {
                            //finished
                            errorMessage = "远程服务器已关闭,无法接收数据";
                            isFailed = true;
                            break;
                        } // 读数据包体本身
数据大于1M,datagram没有完全接收数据,咋办?
2014-08-05 13:05
OTTseawind
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-8-5
得分:0 
新手,有源码示例看下吗?
2014-08-06 13:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-434709-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.121607 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved