Hi guys, as a programming exerise I'm using Winsock to download images. I'm using regular blocking sockets.
// send request
result=send(...);
// I got this from the MS example (see below)
result=shutdown(hSocket,SD_SEND);
// receive
// big buffer
int bufferSize=1048576;
char* buffer=new char[bufferSize];
// receive buffer
int bufferlen=512;
char inbuffer[512];
int total=0;
do {
result=recv(hSocket,inbuffer,bufferlen,0);
if(result > 0){
// copy to big buffer
for(i=0;i<result;i++){
buffer[total+i]=inbuffer[i];
}
total+=result;
}
} while(result > 0);
Am I doing that correctly ? It seems to work alright. Is it true that recv() will block until the buffer I pass to it is full ? If I remove the shutdown line it hangs (but eventually completes), I don't know why. And should I be checking for any specific errors ? I'm just not fully understanding the recv() function.
Thanks.







