FTP LIST problem
-
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);
} -
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);
}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
-
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