4C. FTP-PRG
4C. FTP-PRG
Aim: To implement File Transfer Protocol (FTP) for transferring a file from server to client
application.
1. Create a file which has to be read by the server. Open a notepad, write the file contents
and save it in the program folder sample.txt.
2. Import the required io and net packages.
3. Initialized the socket class for communicate with the server with port number 4000.
4. Client specifies the file name to the server (eg. Sample.txt)
5. Initialize the BufferReader class to read the filename from the terminal.
6. Initialize the PrintWriter class to write and send the file name to the server through the
socket.
7. Initialize BufferReader class to read the file contents from the server.
8. Repeatedly read the data till end of file equals to empty.
9. Close the socket stream, filestream and BufferReader classes
10. End of the program.
Algorithm – Server
Program – Client
Program – Server
Output
Server side
Client side