
my problem is this:
I'm trying to write a program that GETs a file from the HTTP protocol using winsock 2. sending the request is not a problem for me. my problem is receiving binary responses. I can GET a text page BTW.
this is the portion of the code that does the receiving:
FILE *file;
fopen_s(&file , "out.txt" , "wb");
char tempbuf[128];
// Receive until the peer closes the connection
while(true) {
int retval;
retval = recv(ConnectSocket , tempbuf , sizeof(tempbuf)-1 , 0);
if (retval == 0) {
break; // Connection has been closed
}
else {
tempbuf[retval] = 0;
fwrite(tempbuf , 1 , strlen(tempbuf) , file);
}
}
fclose(file);
what is that that I'm doing wrong
I will provide any extra information neccessery.
thanx.