You are on page 1of 15

FILE TRANSFER PROTOCOL

DEFENCE UNIVERSITY
COLLEDGE OF ENGINEERING AND TECHNOLOGY

DEPARTMENT OF COMPUTOR AND INFORMATION TECHNOLOGY

FIRST YEAR POST GRADUATE

INDIVIDUAL PROJECT ON FILE TRANSFER PROTOCOL

NAME:FILIPHOS EYOEL KESHMO

IDENTITY NUMBER:01463410

MAY, 202 1

BOSHOFTU,ETHIOPIA

TABLE OF CONTENTS PAGE


FILE TRANSFER PROTOCOL

1. Description…………………………………………………………………………………………1
2. Objectives…………………………………………………………………………………………..1
3. How it works………………………………………………………………………………………1
4. Problems…………………………………………………………………………………………….2
5. Advantage………………………………………………………………………………………….3
6. Dis advantage…………………………………………………………………………………….3
7. Limitation…………………………………………………………………………………………..3
8. Sample code……………………………………………………………………………………….3
8.1.Server Side……………………………………………………………………………………3
8.2.Client Side…………………………………………………………………………………….5
9. Practical demo……………………………………………………………………………………7

1. Description
FILE TRANSFER PROTOCOL
FTP (File Transfer Protocol) is a protocol designed for transferring files over the internet . Files stored
on an FTP server can be accessed using an FTP client, such as a web browser ,FTP software program or a
command line interface.

2. Objectives
FTP is a widely used network protocol for transferring files between computers over a TCP/IP-based
network ,such as the internet . FTP lets people and applications exchange and share data with in their
offices and across the internet. FTP was one of the first technologies developed to solve this common
need, and it remains with several generations of enhancements.

3. How it works
FTP works in a client-server model where an FTP server and FTPclient perform the file transfer
operation . a FTP server is conjured in the network , and a specific file storage location (folder/system)
is identified to become the shared storage ,which will host the files to share. The end users will access
this file server via FTP to start copying the files to their local folder/system.

FTP requires a TCP/IP network to function ,and relies on the use of one or more FTP clients. The FTP
client act as the communication agent to interact with the server to download or to upload files . in
other words , the FTP client sends out connections to the FTP server . Up on listening to the request
from the client to either upload or download afile .the FTP server performs the file transfer operation.
FILE TRANSFER PROTOCOL

Figure 1

The above figure shows the basic model of the FTP . The FTP client has three components : the user
interface ,control process and data transfer process. The server has two components :the server control
process and the server data transfer process.

4. Problems
 FTP is Not secure
 FTP is Unreliable
 FTP Lacks Features
 FTP is Outdated
FILE TRANSFER PROTOCOL

5. Advantage
FTP is a widely used network protocol for transferring files between computers over a TCP/IP –based
network,such as the internet . FTP lets people and applications exchange and share data with in their
offices and across the internet.

6. Disadvantage
 FTP Lacks security
 FTP Can be vulnerable to attack
 FTP is inhwrently non secure way to transfer data
7. Limitation
FTP does not encrypt traffic that mean passwords and file contents are sent in clear text.Their
force ,FTP may still bbe vulnerable to brute force attack ,packet captures and other hacking attack.

8. Sample Code
8.1. Server Side

import java.net.*;

import java.io.*;

class MyServer {

ServerSocket ss;

Socket clientsocket;

BufferedReader fromclient;

InputStreamReader isr;

PrintWriter toclient;

public MyServer() {

String str = new String("hello");

try {

// Create ServerSocket object.


FILE TRANSFER PROTOCOL
ss = new ServerSocket(1244);

System.out.println("Server Started...");

while(true) {

System.out.println("Waiting for the request...");

// accept the client request.

clientsocket = ss.accept();

System.out.println("Got a client");

System.out.println("Client Address " + clientsocket.getInetAddress().toString());

isr = new InputStreamReader(clientsocket.getInputStream());

fromclient = new BufferedReader(isr);

toclient = new PrintWriter(clientsocket.getOutputStream());

String strfile;

String stringdata;

boolean file_still_present = false;

strfile = fromclient.readLine();

System.out.println(strfile);

//toclient.println("File name received at Server is " + strfile);

File samplefile = new File(strfile);

FileInputStream fileinputstream = new FileInputStream(samplefile);

// now ready to send data from server .....

int notendcharacter;

do {

notendcharacter = fileinputstream.read();

stringdata = String.valueOf(notendcharacter);

toclient.println(stringdata);
FILE TRANSFER PROTOCOL
if (notendcharacter != -1) {

file_still_present = true;

} else {

file_still_present = false;

} while(file_still_present);

fileinputstream.close();

System.out.println("File has been send successfully .. message print from server");

if (str.equals("bye")) {

break;

fromclient.close();

toclient.close();

clientsocket.close();

} catch(Exception ex) {

System.out.println("Error in the code : " + ex.toString());

public static void main(String arg[]) {

MyServer serverobj = new MyServer()

}
FILE TRANSFER PROTOCOL

8.2. Client Side

import java.net.*;

import java.io.*;

class MyClient {

Socket soc;

BufferedReader fromkeyboard, fromserver;

PrintWriter toserver;

InputStreamReader isr;

public MyClient() {

String str;

try {

// server is listening on this port.

soc = new Socket("localhost", 1244);

fromkeyboard = new BufferedReader(new InputStreamReader(System.in));

fromserver = new BufferedReader(new InputStreamReader(soc.getInputStream()));

System.out.println("PLEASE ENTER THE MESSAGE TO BE SENT TO THE SERVER");

str = fromkeyboard.readLine();

System.out.println(str);

String ddd;

ddd = str;

toserver = new PrintWriter(soc.getOutputStream());

String strfile;

int notendcharacter;
FILE TRANSFER PROTOCOL
boolean file_validity = false;

System.out.println("send to server" + str);

System.out.println("Enter the filename to be received from server");

strfile = fromkeyboard.readLine();

toserver.println(strfile);

File samplefile = new File(strfile);

//File OutputStream helps to get write the data from the file ....

FileOutputStream fileOutputStream = new FileOutputStream(samplefile);

// now ready to get the data from server ....

do {

str = fromserver.readLine();

notendcharacter = Integer.parseInt(str);

if (notendcharacter != -1) {

file_validity = true;

} else {

System.out.println("Read and Stored all the Data Bytes from the file ..." +

"Received File Successfully");

if (file_validity) {

fileOutputStream.write(notendcharacter);

} while(file_validity);

fileOutputStream.close();

toserver.close();
FILE TRANSFER PROTOCOL
fromserver.close();

soc.close();

} catch(Exception ex) {

System.out.println("Error in the code : " + ex.toString());

public static void main(String str[]) {

MyClient clientobj = new MyClient();

9.Practical demo
FILE TRANSFER PROTOCOL
FILE TRANSFER PROTOCOL
FILE TRANSFER PROTOCOL
FILE TRANSFER PROTOCOL
FILE TRANSFER PROTOCOL

You might also like