title: How to use raw FTP STOR command
body: <p>I am trying to upload a file to an FTP server using raw commands. Yes, I know there are programs and packages to do this, but mine is an embedded application without such luxuries. My problem is that after successfully issuing all the appropriate commands, I find that the file does not exist on the server.  </p>
  
  <p>Here's what I did:  </p>
  
  <ol>
  <li>I establish a command socket connection to my FTP server on port 21 (Sock1) and receive greeting (code 220)  </li>
  <li>I send "USER <em>myusername</em>" and receive success code 331  </li>
  <li>I send "PASS <em>mypassword</em>" and receive success code 230  </li>
  <li>I send "TYPE I" and receive success code 200  </li>
  <li>I send "PASV" and receive success code 227 along with 6 numbers.  </li>
  <li>I decode these numbers into an IP address and port. They look reasonable.  </li>
  <li>I successfully open a TCP data socket connection to the address and port above (Sock2).  </li>
  <li>I send "STOR <em>myfilename</em>" and receive success code 150.  </li>
  <li>I successfuly send the contents of <em>myfilename</em> to Sock2.  </li>
  <li>I close Sock2, then Sock1.  </li>
  </ol>
  
  <p>Everything seems to have gone Ok, but no file on server. Can anybody tell me what I did wrong?  </p>
  
  <p>I know the server's Ok because I can upload the file using various FTP client programs (using PUT command).</p>