Java Socket Programming - FTP control and data connection?
-
I'm writing a simple FTP client. I want to create an FTP-control connection to send /receive commands only and an FTP-data connection to download file from the FTP server. This is what I got for the control connection: Socket controlSocket = new Socket("localhost", 21); // I setup a test server using FileZilla Server on the same computer I'm running the FTP client // Create input/output streams attached to controlSocket BufferedReader serverIn = new BufferedReader(new InputStreamReader( controlSocket.getInputStream())); PrintWriter serverOut = new PrintWriter( controlSocket.getOutputStream(), true); I have a method sendCommand(String command) which I use to send commands using serverOut. This is what I have for the "data connection": Socket dataSocket = new Socket("localhost", 8000); // not sure if I'm suppose to use same IP as controlSocket DataInputStream din = new DataInputStream( controlSocket.getInputStream()); The thing is when I use serverOut to send the command "PORT ..." then "RETR ...", I get a 425 Can't Open data connection reply. I know it has something to do with FileOutputStream, but I don't know how to use that class. Can someone show me how to set up and download a file through the "data connection" using FileOutputStream?
-
Answer:
You want to create FTP client using Socket programming in Java then u need to check the link given in source.. Good for students.. If u want to do it for personal or professional purpose then use Apache commons FTP.. So u don't need to worry about creating ur own FTP client..
ageoftvb at Yahoo! Answers Visit the source
Related Q & A:
- How to start programming a game in java?Best solution by Game Development
- How to keep socket alive?Best solution by Stack Overflow
- How to access FTP in Java?Best solution by Stack Overflow
- Computer Science Java Programming?Best solution by AllExperts
- Is java or visual basic a machine level, low level, high level or binary level programming language?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.