title: Tftp protocol implementation and difference between netascii and octect
body: <p>I'm building an application that is a server that implements the tftp protocol. I'm having hard times in understand what's the difference between ASCII format and binary format (netascii and octect) in tftp, and how should I read files differently as the protocol states.</p>
  
  <p>I know that an ASCII char can be rapresented with a single byte. So I don't understand what's the difference between reading in ascii mode (1 byte each character) and binary mode (1 raw byte).</p>
  
  <p>I can read the file with flag ios::binary for binary mode (octet in tftp) and without it for ascii (netascii in tftp), but I really don't understand what's the difference in reading files in these two ways (I always come up with an array of bytes).</p>
  
  <p>If someone can help me understand, I'll really appreciate it</p>
  
  <p>The tftp protocol specification: <a href="http://www.rfc-editor.org/rfc/rfc1350.txt" rel="noreferrer">http://www.rfc-editor.org/rfc/rfc1350.txt</a></p>
  
  <p>The part that I don't understand is this one:</p>
  
  <blockquote>
    <p>Three modes of transfer are currently supported: netascii (This is 
    ascii as defined in "USA Standard Code for Information Interchange"<br>
    [1] with the modifications specified in "Telnet Protocol<br>
    Specification" [3].)  Note that it is 8 bit ascii.  The term<br>
    "netascii" will be used throughout this document to mean this<br>
    particular version of ascii.); octet (This replaces the "binary" mode 
    of previous versions of this document.) raw 8 bit bytes; mail,<br>
    netascii characters sent to a user rather than a file.  (The mail<br>
    mode is obsolete and should not be implemented or used.)  Additional<br>
    modes can be defined by pairs of cooperating hosts.</p>
  </blockquote>