Originally Posted by
CommonTater
If you have people uploading files and other people downloading them, you have plain no way to make sure everyone gets compatible files. It's just not a problem the server should try to handle.
Files should be marked with extensions... .txt .exe .zip etc... by the uploader.
It's not your problem.
but the uploading file is marked with extensions...here's the uploading code:
client (uploader)
Code:
FILE* fp = fopen(buffer,"rb"); // buffer = "server.txt"
printf("uploading...\n");
while(!feof(fp)){
bzero(buffer,150);
fread(buffer,sizeof(char),150,fp);
send(sockfd,buffer,150,0);
if (n < 0)
error("ERROR writing to socket");
}
write(sockfd,"quit",150);
fclose(fp);
server (receiver)
Code:
FILE* fp = fopen(buffer,"wb"); // buffer contains the name sent by client: "server.txt"
while(1){
// bzero(buffer,150);
recv(sock,buffer,150,0);
if(strcmp(buffer,"quit")==0)
{
break;
}
fwrite(buffer,1,150,fp);
}
fclose(fp);
after this...i get a "server.txt" on server directory but i can't open it due to "character codifying" issues