title: C / C++ - How to download byte by byte (like a file stream) from the web?
body: <p>I'm building a simple download and file transfer manager in C and C++, with support for pause and resume operations.
  I looked for a way to download byte by byte from a given URL, but all I could find were references to external libraries like libcurl. I don't want external libraries, I want to manually read and write the bytes in a similar way used to read and write bytes to files (like ifstream in C++, and fopen in C) using only the C/C++ native library.
  The pseudo-code for what I need would be:</p>
  
  <pre><code>void download(file, url) {
      file.open();
      url.open();
      set_active(true);
      while( ! pause() ) {
          bytes_read = url.read(byte_array);
          if(bytes_read &lt; 1)
              break;
          file.write(byte_array, bytes_read);
      }
      url.close();
      file.close();
      set_active(false);
  }
  </code></pre>
  
  <p>How would that pseudo-code work in both C and C++?</p>
  
  <hr>
  
  <p>EDIT: I don't want external libraries for the simple interest on learning the capabilities and limits of both languages and their native libraries.</p>
  
  <p>EDIT 2: Conclusion: Neither of the languages have native support for HTTP operations, therefore I have to choose between a using third-party library or writing a HTTP (and several other protocols) implementation from the scratch, which is unreliable. Thanks.</p>