0% found this document useful (0 votes)
8 views4 pages

4C. FTP-PRG

The document outlines the implementation of a File Transfer Protocol (FTP) using TCP sockets for transferring files from a server to a client. It details the steps for both client and server, including file creation, socket initialization, and data transmission. The algorithm specifies the necessary imports, reading and writing processes, and the closing of streams at the end of the program.

Uploaded by

maplagay18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

4C. FTP-PRG

The document outlines the implementation of a File Transfer Protocol (FTP) using TCP sockets for transferring files from a server to a client. It details the steps for both client and server, including file creation, socket initialization, and data transmission. The algorithm specifies the necessary imports, reading and writing processes, and the closing of streams at the end of the program.

Uploaded by

maplagay18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

4C.

TCP socket – File Transfer

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

1. Import the required io and net packages.


2. Initialized the SeverSocket class and accept the client connection.
3. Initialize the BufferReader class for reading the client request (ie file name)
4. Initialize the FileReader class for reading the file.
5. Initialize Buffer Reader class for reading the file contents line by line.
6. Repeatedly read the file content line by line and send to the client through the socket S.
7. Close the socket stream, BufferedReader.

Program – Client
Program – Server
Output
Server side
Client side

You might also like