Take the 2-minute tour ×  Actually i'm working on very simple
ftp server. Now i have problem with sending file (RETR in ftp
protocol). I'm using sockets and binary mode in my client. Files
with text sends perfectly but problem is binary files (images
etc.).  Here's piece of my code:  FILE *fin=fopen(fileloc,"rb");
if(fin != NULL){                 fpos_t filelen;
fseek (fin, 0, SEEK_END);                 fgetpos (fin,
&filelen);                  fseek (fin, 0, SEEK_SET);
printf("Sending file %s (%d b)", fileloc, filelen);
sprintf(sbuffer,"150 Opening BINARY mode data connection for
file transfer.\r\n");                 bytes = send(ns, sbuffer,
strlen(sbuffer), 0);                 byte temp_buffer[512];
long int totalsent;                 totalsent = 0;
while (!feof(fin)){                      memset(temp_buffer,
'\0', sizeof(sbuffer));                      fgets((char
*)temp_buffer, sizeof(sbuffer), fin);