I have a web service written in .net on a remote computer with IIS, I am trying to connect to it with a C program using socker to do a SOAP request.
My problem is that I have some probem receiving the data:
The receiving data loop does not work in a way or in another.
If I write:
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
}
}
sometime does not return all data, if it run without debugger and breackpoints.
If I try: while(nByte!=0)
at the end of data it stalls and go in error.
How is it supposed to be done? Thanks, Antonino
** EDIT ** I resolved my situation in another way, I check the returned value for 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;
}
}
It is very sad...
Where does it say it fills the buffer? Read the man image. It blocks until at least one byte of data can be transferred, then transfers whatever data has arrived.