Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FTP LIST problem

FTP LIST problem

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monin D
    wrote on last edited by
    #1

    How to recieve a List of files from a ftp? I am sending command LIST. but recieving only: 150 Opening ASCII mode data connection for /bin/ls. 226 Transfer complete. I am sure that on ftp must be some folders and files (ftp clients show them). But I dont receive anything between 150 and 226. So I read the answer from ftp:

    Socket clientSocket; // Assume that I am already connected and logged on to ftp
    string message;
    byte[] buffer = byte[512];
    int bytes;
    while (clientSocket.Available == 0)
    {
    // on timeout throw error
    System.Threading.Thread.Sleep(50);
    }

    while (clientSocket.Available > 0)
    {
    bytes = clientSocket.Receive(buffer, buffer.Length, 0);
    message += Encoding.ASCII.GetString(buffer, 0, (int)bytes);
    System.Threading.Thread.Sleep(50);
    }

    S 1 Reply Last reply
    0
    • M Monin D

      How to recieve a List of files from a ftp? I am sending command LIST. but recieving only: 150 Opening ASCII mode data connection for /bin/ls. 226 Transfer complete. I am sure that on ftp must be some folders and files (ftp clients show them). But I dont receive anything between 150 and 226. So I read the answer from ftp:

      Socket clientSocket; // Assume that I am already connected and logged on to ftp
      string message;
      byte[] buffer = byte[512];
      int bytes;
      while (clientSocket.Available == 0)
      {
      // on timeout throw error
      System.Threading.Thread.Sleep(50);
      }

      while (clientSocket.Available > 0)
      {
      bytes = clientSocket.Receive(buffer, buffer.Length, 0);
      message += Encoding.ASCII.GetString(buffer, 0, (int)bytes);
      System.Threading.Thread.Sleep(50);
      }

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      If I remember correctly, FTP uses two TCP ports (20 and 21), the latter for sending/receiving commands and the former for sending/receiving data. Are you connecting to the server's port 20?

      Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

      M 1 Reply Last reply
      0
      • S S Senthil Kumar

        If I remember correctly, FTP uses two TCP ports (20 and 21), the latter for sending/receiving commands and the former for sending/receiving data. Are you connecting to the server's port 20?

        Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

        M Offline
        M Offline
        Monin D
        wrote on last edited by
        #3

        Thank you for idea! The solution was so, that i was have to create one more data socket for passive mode on another port and receive data from this socket.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups