title: sending an image through a socket in C++
body: <pre><code>std::ifstream file(localPath.c_str(), std::ifstream::binary);
  
  file.seekg(0, std::ifstream::beg);
  
  while(file.tellg() != -1)
  {
      char *p = new char[1024];
  
      bzero(p, 1024);
      file.read(p, 1024);
  
      printf("%ld\n", file.gcount());
  
      n = send(fd, p, strlen(p), 0);
      if (n &lt; 0) {
          error("ERROR writing to socket");
      } else {
          printf("---------%d\n", n);
      }
  
      delete p;
  }
  
  file.close();
  </code></pre>
  
  <p>Actually the image which I m trying to send is png (size: 27892bytes) As far as reading is concerned every byte is being read properly. But, while writing them into socket only few bytes are being written. Need help on this.</p>
  
  <p>Thanks in advance. :)</p>