Talking to an FTP server --- please help!

A

almurph

Hi everyone,


Can you help me please? I am trying to login into to an FTP server. I
can successfully reach the server and it sends me a welcome message
but after that I don't know how to send down the username, password
etc...It identifies itself as: "Pure-FTPd"

Is there any way I can find out this by asking the server in some way
as to the format that it accepts? Do you know what I mean? Any
suggestions/comments/useful code samples/advice would be most
appreciated.

Thanks in advance,
Al



**** CODE AS FOLLOWS ****

System.Net.Sockets.TcpClient mtTCPClient = new
System.Net.Sockets.TcpClient(FTPUrl, portNo);
System.Net.Sockets.NetworkStream myNS = mtTCPClient.GetStream();


//2. Read something
if (myNS.CanRead )
{
byte[] myReadBuffer = new byte[1024];
String myCompleteMessage = "";
int numberOfBytesRead = 0;
// Incoming message may be larger than the buffer size.
do
{
numberOfBytesRead = myNS.Read(myReadBuffer, 0,
myReadBuffer.Length);
myCompleteMessage = String.Concat(myCompleteMessage,
System.Text.Encoding.ASCII.GetString(myReadBuffer, 0,
numberOfBytesRead));
}
while(myNS.DataAvailable);
}


**** END CODE ****
 
P

Peter Morris

It's a protocol, so it should be the same for all servers. If you need it
to be easier try some FTP components, rebex for example.
 
J

Jon Skeet [C# MVP]

Can you help me please? I am trying to login into to an FTP server. I
can successfully reach the server and it sends me a welcome message
but after that I don't know how to send down the username, password
etc...It identifies itself as: "Pure-FTPd"

Is there any way I can find out this by asking the server in some way
as to the format that it accepts? Do you know what I mean? Any
suggestions/comments/useful code samples/advice would be most
appreciated.

You look at the RFC for FTP:

http://www.faqs.org/rfcs/rfc959.html
 
A

Arne Vajhøj

Can you help me please? I am trying to login into to an FTP server. I
can successfully reach the server and it sends me a welcome message
but after that I don't know how to send down the username, password
etc...It identifies itself as: "Pure-FTPd"

Is there any way I can find out this by asking the server in some way
as to the format that it accepts? Do you know what I mean? Any
suggestions/comments/useful code samples/advice would be most
appreciated.

First: are you sure that you can not use the builtin classes
in .NET since version 2.0: FtpWebRequest/Response ?

Secondly: the FTP protocol is a bit tricky (at least more
than HTTP, SMTP etc.). You can start studying the FTP RFC.
I also have some code I created for .NET 1.1 to have FTP and
still use on newer .NET versions if the builtin does not
work as I want it. IF you are interested I can post a link.

Arne
 
C

Cuong

Arne Vajhøj said:
First: are you sure that you can not use the builtin classes
in .NET since version 2.0: FtpWebRequest/Response ?

Secondly: the FTP protocol is a bit tricky (at least more
than HTTP, SMTP etc.). You can start studying the FTP RFC.
I also have some code I created for .NET 1.1 to have FTP and
still use on newer .NET versions if the builtin does not
work as I want it. IF you are interested I can post a link.

Arne

Could you post the link? I would like to take a look....
Thanks!
 

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