title: WinInet ftp connection error 123
body: <p>I'm trying to connect to my ftp server via C++/WinInet, but I keep receiving error 123 (ERROR_INVALID_NAME). Google research says that this error is caused by wrong server address, but my address is valid, same as my username and password. Here's my code:</p>
  
  <pre><code>void FileSubmit(LPCWSTR addr, LPCWSTR login, LPCWSTR pass, LPCWSTR pcFile, LPCWSTR ftpFile)
  {
      HINTERNET hInternet;
      HINTERNET hFtpSession;
      hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
      if (hInternet == NULL)
      {
          cout &lt;&lt; "Error: " &lt;&lt; GetLastError();
      }
      else
      {
          cout&lt;&lt;"Connecting to :"&lt;&lt;(char*)login&lt;&lt;" @ "&lt;&lt;(char*)addr&lt;&lt;", to upload file from PC: "&lt;&lt;(char*)pcFile&lt;&lt;" as "&lt;&lt;(char*)ftpFile&lt;&lt;endl;
          hFtpSession = InternetConnect(hInternet, addr, INTERNET_DEFAULT_FTP_PORT, 
                      login, pass, INTERNET_SERVICE_FTP, NULL, NULL);
          if (hFtpSession == NULL)
          {
              cout&lt;&lt;"FTPSESSION ERROR!\n";
              cout &lt;&lt; "Error: " &lt;&lt; GetLastError();
          }
          else
          {
              cout&lt;&lt;"hFTPsession successfull!\n";
              if (!FtpPutFile(hFtpSession, pcFile, ftpFile, FTP_TRANSFER_TYPE_BINARY, 0))
              {
                  cout &lt;&lt; "Error: " &lt;&lt; GetLastError();
              }
              else
                  cout&lt;&lt;"FILE "&lt;&lt;(char*)pcFile&lt;&lt;" HAS BEEN SUCCESSFULLY UPLOADED AS "&lt;&lt;(char*)ftpFile&lt;&lt;"!\n";
          }
      }
  }
  </code></pre>
  
  <p>I'm using it like:</p>
  
  <pre><code>FileSubmit((LPCWSTR)"ftp.ibieda.cba.pl",(LPCWSTR)"login",
                 (LPCWSTR)"pass",(LPCWSTR)"C:\\file.txt",(LPCWSTR)"\\file.txt");
  </code></pre>
  
  <p>can anybody help and tell me why is InternetConnect returning 123 (ERROR_INVALID_NAME) ?</p>