我的socket服务端接收程序,在接受小规模数据时没有发生错误,但是当接收超过40k的图片处理程序时。就会出现10035的错误,麻烦各位兄弟姐妹给看看。
接受接收程序如下:
public void StartReceive(object obj)
{
InterfaceDataOper idoDataOper = null;
Int32 intCount = 0;//用于存放接收到的Byte数 try
{
while (true)
{
try
{
intCount = socReceive.Receive(bytPHeader); if (idoDataOper == null && intCount >= 1)
{
idoDataOper = rtnOpinionIF(bytPHeader);
} bytBuffer = new byte[Int32BufLength]; intCount = socReceive.Receive(bytBuffer);
if (intCount == 0)
{
break;
}
else if (idoDataOper == null)
{
break;
}
else if (bytBuffer.Length == intCount) //判断数据是否接收完成。
{
break;
}
}
} if (idoDataOper == null)
{
//接收到的数据不完整,或数据接收错误
}
else
{
idoDataOper.DataSocket(socReceive);
idoDataOper.ClientAcitve(bytPHeader, bytBuffer);
} }
catch (Exception ex)
{
MessageLog.RecLogAndMessage("错误", ex);
} } private InterfaceDataOper rtnOpinionIF(byte[] bytHeader)
{
String strProtocolVersion,strPLength;
strProtocolVersion = System.Text.Encoding.ASCII.GetString(bytHeader,0, 2); strPLength = System.Text.Encoding.ASCII.GetString(bytHeader, 4, 4);
Int32BufLength = Convert.ToInt32(strPLength,16) ;
switch (strProtocolVersion)
{
case "1":
//
default:
return new InstanceIFTest();
} }
接受接收程序如下:
public void StartReceive(object obj)
{
InterfaceDataOper idoDataOper = null;
Int32 intCount = 0;//用于存放接收到的Byte数 try
{
while (true)
{
try
{
intCount = socReceive.Receive(bytPHeader); if (idoDataOper == null && intCount >= 1)
{
idoDataOper = rtnOpinionIF(bytPHeader);
} bytBuffer = new byte[Int32BufLength]; intCount = socReceive.Receive(bytBuffer);
if (intCount == 0)
{
break;
}
else if (idoDataOper == null)
{
break;
}
else if (bytBuffer.Length == intCount) //判断数据是否接收完成。
{
break;
}
}
} if (idoDataOper == null)
{
//接收到的数据不完整,或数据接收错误
}
else
{
idoDataOper.DataSocket(socReceive);
idoDataOper.ClientAcitve(bytPHeader, bytBuffer);
} }
catch (Exception ex)
{
MessageLog.RecLogAndMessage("错误", ex);
} } private InterfaceDataOper rtnOpinionIF(byte[] bytHeader)
{
String strProtocolVersion,strPLength;
strProtocolVersion = System.Text.Encoding.ASCII.GetString(bytHeader,0, 2); strPLength = System.Text.Encoding.ASCII.GetString(bytHeader, 4, 4);
Int32BufLength = Convert.ToInt32(strPLength,16) ;
switch (strProtocolVersion)
{
case "1":
//
default:
return new InstanceIFTest();
} }
解决方案 »
- 跪求Transfer-Encoding: chunked的解析代码!!
- byte数组还原PNG图片
- C# winform(WebBrowser) 多线程问题
- string和char 的问题
- 这个接口属于哪个命名空间?
- winform 下 由bit类型数据库字段 填充的DATAGRIDCHECKBOX列的问题!!!!!!!!!!!!!
- 使用C#语言,通过调用XML,来实现对树形结构的数据进行增删改查
- 请问一个c#操作数据库的问题
- 强烈要求upto(阿球)进来看看,比较这两个贴子,请问哪个更像倒分!(欢迎大家来up)
- WPF如何为WinForm控件添加依赖属性?
- 我想在C#里面定义一个类型的别名,类似于C++里面的TypeDefine那样
- Solution大了,发现原来的一些文件结构很乱,想整理一下
是表示在非阻塞Sockets不能完成操作,例如在調用Receive的時候,從socket中沒有數據讀出,這個錯誤不是致命的,在之後是可以恢復正常的.當出現錯誤時,你的程序可以繼續嘗試接收