I am sending a file from client to server by partition the file small part which size is 2048 and send each part . Below is my code. Please advise. tks.
FILE *fp;
    fp= fopen(t.c_str(),"r");// t is the filename string
    if(fp == NULL)
    {
      printf("error to open %s",t.c_str());
      exit(1);
    }
    fseek(fp, 0, SEEK_END);
    int size = ftell(fp);
    rewind(fp);
    int count = size/2048;
    int remainder = size %2048;
  Â
    char * buffer = (char*)malloc(sizeof(char) *size);
    char *p;
    p= buffer;
    // copy the file into the buffer:
    int result = fread (buffer,1,size,fp);
   Â
    if (result != size)
    {
      printf(" Reading error",stderr);
    }
   Â
    if( count >= 2048)
    {
       for( int i= 0; i < count;i++)
       {
         send(sock, p, 2048,0);
         p = p+2048;
       }
   Â
       //send the remainder trunk
       send(sock, p, remainder, 0);
    }
    else
    {
       send(sock, p, size, 0);
    }
  Â