char buf[BLEN];
char *bptr;
int n;
int buflen;
bptr = buf;
buflen = BLEN;
Int n =recv(s,bptr,buflen,0);
while (n!=0)
{
bptr +=n;
buflen -=n;
n = recv(s,bptr,buflen,0);
}
}
Go to msdn.microsoft.com, search for recv(). You will find the documentation
for that function there, including the meaning of it returning -1. I don't
remember if it was errno, GetLastError() or WSAGetLastError() which you
should use to find further info, but that's documented there, too.
> bptr = buf;
> buflen = BLEN;
Why? You can directly pass an array to recv(), C will pass the address of
its first element instead ("array to pointer decay").
> Int n =recv(s,bptr,buflen,0);
> while (n!=0)
For the record, n==0 is also possible.
Anyhow, recv() returning -1 usually means that the other side closed the
connection without first calling shutdown() to properly flush any buffers.
Uli
--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932