Have you read the RFC on how FTP works?
You can use a Socket connection to send the FTP server commands made of Strings.
You need to know the protocol for it to work.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
That could work. Try it and see how it goes.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
With FTP you send a request to the server. The server does what you ask.
You need to read the doc on the protocol. One place is the RFC doc for FTP.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Connect to the server and send the command as a String.
I don't know if this will be helpful or confusing. I wrote an FTP Server a few years ago.
Here is its console log from when I connect to it with a FTP tool: WS_FTP95.
FTPrun(): connected accepted Socket[addr=/127.0.0.1,port=4145,localport=21]
ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=21]
MyIP4PASV: 127,0,0,1,
writeString: writing >220 Norms FTP server ready.
< (end of writing) <<<
FTPreq: >USER Norm<
writeString: writing >331 Password required.
< (end of writing) <<<
FTP req: PASS asdf
writeString: writing >230 User logged in.
< (end of writing) <<<
FTP request: PWD
writeString: writing >257 "D:/www/" is current directory.
< (end of writing) <<<
FTP request: SYST
writeString: writing >215 NAME Norm's FTP Server
< (end of writing) <<<
FTP request: HELP
writeString: writing >214-The following commands are recognized:
USER
QUIT
ABOR
TYPE
LIST
PWD
MKD
CWD
TYPE
PORT
SYST
HELP
NLST
CDUP
PASV
RETR
STOR
214 Help command successful.
< (end of writing) <<<
FTP request: PORT 127,0,0,1,16,50
dpH RmtAddr: 127.0.0.1:4146
dpH OSocket: Socket[addr=/127.0.0.1,port=4146,localport=20]
writeString: writing >220 PORT Command successful.
< (end of writing) <<<
FTP request: LIST
writeString: writing >150 Opening ASCII mode data connection.
< (end of writing) <<<
dpHdoLIST: >< true
writeString: writing >226 Transfer complete.
< (end of writing) <<<
FTP request: PWD
writeString: writing >257 "D:/www/" is current directory.
< (end of writing) <<<
FTP request: PORT 127,0,0,1,16,51
dpH RmtAddr: 127.0.0.1:4147
dpH OSocket: Socket[addr=/127.0.0.1,port=4147,localport=20]
writeString: writing >220 PORT Command successful.
< (end of writing) <<<
FTP request: LIST
writeString: writing >150 Opening ASCII mode data connection.
< (end of writing) <<<
dpHdoLIST: >< true
writeString: writing >226 Transfer complete.
< (end of writing) <<<
FTP request: QUIT
User: Norm logged off
writeString: writing >221 Goodbye.
< (end of writing) <<<
FTPrun(): waiting on connect at Mon Jan 23 21:07:52 EST 2012 ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=21]
The Strings inside of the > < are what the server received or sent.
The one in red was received from the client.
The one in green was what was sent to the client
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
See my last post. It has part of a dialog between a FTP server and a client.
The client was an FTP tool I got years ago. I suspect it uses sockets.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
how to send FTP commands.
Use the output stream you get from a Socket.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
How does the short piece of code relate to the stack trace?
For example: Where is line 155
What is the value of the variable: url?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Congratulations on getting your code to work.
I wouldn't say it was finished, but at least you have the basics done.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16