Need help with ftp commands???

D

DaveF

I am not to familiar with ftp, but in the code I do the following, and it
does not work...

ff.setGetCamera("cameras.tar.gz");

sendCommand("GET "+remFileName);
if (retValue != 200)
{
//throw new IOException(reply.Substring(4));
}
}

private void sendCommand(String command)
{

Byte[] cmdBytes =
Encoding.ASCII.GetBytes((command+"\r\n").ToCharArray());
clientSocket.Send(cmdBytes, cmdBytes.Length, 0);
readReply();
}
 
N

Nicholas Paldino [.NET/C# MVP]

Dave,

When you send a GET command to an FTP server, a secondary connection is
opened to do the actual transferring of the file. The response you get from
the GET command should tell you where you can connect (host and port) in
order to get the file. If you are using passive connections, then the
response to your command would indicate that the connection has been
estabilished to you.

Hope this helps.
 
D

DaveF

You just went over my head?

Nicholas Paldino said:
Dave,

When you send a GET command to an FTP server, a secondary connection is
opened to do the actual transferring of the file. The response you get from
the GET command should tell you where you can connect (host and port) in
order to get the file. If you are using passive connections, then the
response to your command would indicate that the connection has been
estabilished to you.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DaveF said:
I am not to familiar with ftp, but in the code I do the following, and it
does not work...

ff.setGetCamera("cameras.tar.gz");

sendCommand("GET "+remFileName);
if (retValue != 200)
{
//throw new IOException(reply.Substring(4));
}
}

private void sendCommand(String command)
{

Byte[] cmdBytes =
Encoding.ASCII.GetBytes((command+"\r\n").ToCharArray());
clientSocket.Send(cmdBytes, cmdBytes.Length, 0);
readReply();
}
 
C

Chad Z. Hower aka Kudzu

DaveF said:
I am not to familiar with ftp, but in the code I do the following, and it
does not work...

FTP requires TWO connections and is not a trivial protocol to implement. If
you really want to write your own using a raw TCP socket you have a LOT of
work ahead of you.

You might consider Indy, its free and has the most comprehensive FTP support
available. Its also free.

www.indyproject.org
 
F

Fakher Halim

I tried INDY site, but couldn't find a single C# FTP example for any upload,
download. While it is certainly perhaps the richest (120 TCP/IP protocols)
library, the lack of practical C# usage example for FTP is the biggest
obstacle in its wide spread acceptance in .NET community.

Fakher Halim
 
C

Chad Z. Hower aka Kudzu

Fakher Halim said:
I tried INDY site, but couldn't find a single C# FTP example for any
upload, download. While it is certainly perhaps the richest (120 TCP/IP
protocols) library, the lack of practical C# usage example for FTP is
the biggest obstacle in its wide spread acceptance in .NET community.

Open Source needs volunteers to make is successful - demos just like anything
else come from volunteers.

But you've seen that now - you've got the FTP article up on CodeProject.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top