Hello, I have a program that is like a ftp server - it sends and receives files over unix sockets.
It works fine when I transfer text files, but as soon as I want to receive binary files, it's not working properly.
Files are transferred correctly, I can verify that with diff.
The problem is-- after the file is sent then reading the next command (like put, get or list) from user gives some garbage and then the user input
But after the server reads the garbage line, the next command is executed correctly again.
The server code http://pastebin.com/AazSQU1L
client code http://pastebin.com/gYNegySh
you can use nc (netcat) instead of the client when uncommenting line 85 from the server
usage g [file name] or l for directory listing
the important part of the transfer function might be this:
while(1){
if(feof(fp)){
printf("done sending file, last slice length: %d\n", readcount);
break;
}
readcount = fread(string, 1, BUFLEN, fp);
out(client_fd, string, readcount);
}
Hope you can give me some advice with that