How to create socket connection with php?

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

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

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.