我在带有 IIS 的远程计算机上使用 .net 编写了一个 Web 服务,我正在尝试使用一个 C 程序连接到它,该 C 程序使用 socker 来执行 SOAP 请求。
我的问题是我有一些接收数据的问题:
接收数据循环不能以某种方式或以另一种方式工作。
如果我写:
nByte = 1;
while(nByte!=512)
{
nByte = recv(sockfd,buffer,512, 0);
if( nByte < 0 )
{
// check the error
}
if( nByte > 0)
{
// append buffer to received data
}
}
如果它在没有调试器和断点的情况下运行,有时不会返回所有数据。
如果我尝试:while(nByte!=0)
在数据结束时它会停止并出错。
应该怎么做?谢谢,安东尼诺
**编辑** 我以另一种方式解决了我的情况,我检查了soap xml end 的返回值:
nByte = 1;
while(nByte!=0)
{
nByte = recv(sockfd,buffer,512, 0);
if( nByte < 0 )
{
// check the error
}
if( nByte > 0)
{
// append nByte buffer to received data
if( strstr("</soap:Envelope>", buffer) != NULL)
break;
}
}
这是非常可悲的...