You are on page 1of 95

MAULANA AZAD NATIONAL INSTITUTE OF TECHNOLOGY

BHOPAL

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


MINOR PROJECT
ON

P2P File Transfer cum Chat System


SUBMITTED IN PARTIAL FULFILLMENT FOR THE DEGREE OF BACHELOR OF TECHNOLOGY

SUBMITTED BY:
SHWETA GUPTA

JITENDRA GUPTA
AJEETPANDEY

ANURODH TRIPATHI

131112041

131112032
131112034
131112030

UNDER THE GUIDANCE OF


Dr. Praveen Kaushik

SESSION 2015-2016
FTP|MINOR PROJECT

MAULANA AZAD NATIONAL INSTITUTE OF TECHNOLOGY


BHOPAL

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CERTIFICATE
This is to certify that Shweta Gupta, Jitendra Gupta, Ajeet Pandey and
Anurodh Tripathi students of B.Tech. 3rd Year (Computer Science &
Engineering), have successfully completed their project P2P File Transfer cum
Chat Server in partial fulfillment of their minor project in Computer Science &
Engineering.

Dr. Praveen Kaushik


(Project Guide)

Prof. Shweta Jain

(Project coordinator)

FTP|MINOR PROJECT

MAULANA AZAD NATIONAL INSTITUTE OF TECHNOLOGY


BHOPAL

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

DECLARATION

We, hereby, declare that the following report which is being presented in the Minor Project Documentation entitled
P2P

File Transfer cum Chat Server is the partial fulfillment of the requirements of the third year (sixth

semester) Minor Project in the field of Computer Science And Engineering. It is an authentic documentation of our own
original work carried out under the able guidance of Prof. Shweta Jain and the dedicated co-ordination of Prof. Praveen

Kaushik. The work has been carried out entirely at Maulana Azad National Institute of Technology, Bhopal. The
following project and its report, in part or whole, has not been presented or submitted by us for any purpose in any other
institute or organization.

We, hereby, declare that the facts mentioned above are true to the best of our knowledge. In case of any unlikely
discrepancy that may possibly occur, we will be the ones to take responsibility.

SHWETA GUPTA

131112041

AJEET PANDEY

131112034

JITENDRA GUPTA
ANURODH TRIPATHI

131112032
131112030

FTP|MINOR PROJECT

ACKNOWLEDGEMENT
With due respect, we express our deep sense of gratitude to our respected guide Prof.
Guide, for her valuable help and guidance. We are thankful for the encouragement that
she has given us in completing this project successfully. Her rigorous evaluation and
constructive criticism was of great assistance.
It is imperative for us to mention the fact that this minor project could not have been
accomplished without the periodic suggestions and advice of our project coordinator
Prof. Praveen Kaushik.
We are also grateful to our respected Director Dr. Narendra S. Chaudhary for permitting
us to utilize all the necessary facilities of the college.
Needless to mention is the additional help and support extended by our respected HOD,
Dr. R. K. Pateriya, in allowing us to use the departmental laboratories and other
services.
We are also thankful to all the other faculty, staff members and laboratory attendants of
our department for their kind co-operation and help.
Last but certainly not the least; we would like to express our deep appreciation towards
our family members and batch mates for providing the much needed support and
encouragement.

FTP|MINOR PROJECT

CONTENTS
S. No.

Title

Declaration

Abstract

Introduction
1.1 Types of Peer to Peer
1.1.1 Unstructured P2P
1.1.2 Centralized P2P
1.2 Applications
1.3 Advantages
1.4 Objective
1.5 Scope
Features Of Project

2
3

Hardware and Software Requirements


3.1 Input Requirements
3.2 Output Requirements
3.3 Software Requirements
3.4 Hardware Requirements
Technology to be used
4.1 Multi-Threading
4.1.1 Benefits of using threads
4.1.2 Life Cycle of a Thread
4.2 Socket Programming in Java
4.2.1 Ports and Sockets
4.3 Networking In Java

Acknowledgement
List Of Figures
1

Page no.

13

14

16

FTP|MINOR PROJECT

P2P Architecture

23

Code And Results

28

Flow charts

Testing

Security Analysis

10
11
.

79

88

Future & further enhancement of Project

92

Appendix

94

References

12

24

93

FTP|MINOR PROJECT

LIST OF FIGURES

Tables Page No.


5.1 Thread Priority ..............18

5.1 Life Cycle Of Thread....17


5.3 Socket Programming .........19
5.3.1 Connection request from Client......20

5.3.2 Connection Build From Server............21


9.2.1 P2P Architecture ..36
12.1 Data Flow Diagrams Notations.50

FTP|MINOR PROJECT

ABSTRACT

The peer-to-peer (P2P) file sharing protocol has evolved from depending on Internet connection
provided by the local network, to free Internet connectivity through Wi-Fi & Ethernet
technology. On the other hand, IEEE 802.15.4 is considered as todays one of the top growing
wireless protocol.

Peer to Peer file sharing systems are discussed in a lot of academic research. Many Peer to Peer
applications are available which work on the computer such as Gnutella, Napster, Bittorent , and
SymTorrent . File sharing causes a lot of the traffic on the network, thus some of the technology
is used to reduce the traffic and find the files easily. Devices are becoming multifunctional, so
why not create a peer-to-peer file sharing system between the devices.
The application allows J2ME and MIDP (Mobile Information Device Profile) enabled devices to
share and publish the files in the network over Ethernet search for specific types of files such as
(music, picture, text, and program) and download them onto its local memory. It is possible to
develop the system in the future, to add more features and the capacity to work on more than one
operating system for devices & android application for mobile. The application was implemented
and tested successfully between more than two devices using ethernet and an emulator in
Wireless toolkit. The application fulfils the basic requirements for peer-to-peer file sharing. In
addition, the application was implemented on two devices successfully, and we can share files
and messaging as well. The application allows the user to share and search for any type of file
connected with a local server.

FTP|MINOR PROJECT

INTRODUCTION
The project is Java Based Peer to Peer (P2P) File Sharing System with chat. Point-to-Point (P2P)
technology enables the sharing of computer resources such as files by a direct exchange between
end-users computers. P2P networking means files are not stored on a central server. Instead,
client works as a server for shared files on an individual's computer. This allows each computer
with the software to act as a mini-server from which other P2P users can download files. P2P's
popularity stems from its easy-to-use, convenient setup that has empowered informal networks
of file sharers to make files available to each other around the globe.
P2P communication has the following characteristics:
Direct connections between network clients

Each client (node) is considered as an equal to all others


Clients share processing, applications and content

There is no central point of control within the network.


Peer-to-peer computing is the sharing of computer resources and services by direct exchange
between systems. In a peer-to-peer architecture, computers that have traditionally been used
solely as clients communicate directly among themselves and can act as both clients and a server,
assuming whatever role is most efficient for the network. Another big attraction of file-sharing
is cost : Users can download as many songs as they like from each other, for free. With the price
of CDs often well over $20, many music-lovers have engaged in file-sharing despite the legal
risks involved. Moreover, many consumers are loath to spend $20 for a compilation of songs
when they are really only interested in one of the tracks on the CD. They may turn to file-sharing
in order to download the one song that they want, without having to purchase the full CD.

What is Peer to Peer Networking?

A wide-area, resource sharing network for sharing Processing, files, storage


All nodes are considered equal as opposed to client-server
Auto-discovery of peers
Resources at edge of network (in homes & offices) rather than centralized managed servers.
Users contribute resources
Efficient algorithms needed for data placement across many nodes and subsequent access to
data

FTP|MINOR PROJECT

Graphical representation of peer-2-peer network

1.1 Types of Peer To Peer Network


1.1.1 Unstructured peer-to-peer network: It does not impose any structure on the overlay
networks. Peers in these networks connect in an ad-hoc fashion. Ideally, unstructured P2P
systems would have absolutely no centralized system, but in practice there are several types of
unstructured systems with various degrees of centralization. There are two main types of
unstructured P2P networks:

Pure peer-to-peer systems: The entire network consists solely of equipotent peers. There
is only one routing layer, as there are no preferred nodes with any special infrastructure
function.
Hybrid peer-to-peer systems: These systems allow such infrastructure nodes to exist,
often called super nodes. A pure P2P network does not have the notion of clients or
servers but only equal peer nodes that simultaneously function as both "clients" and
"servers" to the other nodes on the network. 1.1.2 Centralized peer-to-peer network: In
this, central server is used for indexing functions and to bootstrap the entire system.
Although this has similarities with a structured architecture, the connections between
peers are not determined by any algorithm.

10

FTP|MINOR PROJECT

1.2 Applications
1.
2.
3.

Many file sharing networks, such as gnutella, G2 and the eDonkey network popularized peer
to peer technologies. From 2004 on, such networks form the largest contributor of network
traffic on the Internet.
Peer-to-peer content delivery networks (P2P-CDN). Peer-to-peer content services, e.g.
caches for improved performance such as Correli Caches.
Software publication and distribution (Linux, several games) via file sharing networks.

1.3 Advantages
1. In P2P networks clients provide resources, which may include bandwidth, storage space
and computing power. This property is one of the major advantages of using P2P
networks because it makes the setup and running costs very small for the original content
distributor. As nodes arrive and demand on the system increases, the total capacity of the
system also increases, and the likelihood of failure decreases. If one peer on the network
fails to function properly, the whole network is not compromised or damaged. In contrast,
in a typical clientserver architecture, clients share only their demands with the system,
but not their resources. In this case, as more clients join the system, fewer resources are
available to serve each client, and if the central server fails, the entire network is taken
down.
2. The decentralized nature of P2P networks increases robustness because it removes the
single point of failure that can be inherent in a client-server based system.
3. Another important property of peer-to-peer systems is the lack of a system administrator.
This leads to a network that is easier and faster to setup and keep running because a full
staff is not required to ensure efficiency and stability. Decentralized networks introduce
new security issues because they are designed so that each user is responsible for
controlling their data and resources. A user may encounter harmful data by downloading
a file that was originally uploaded as a virus disguised in an .exe, .mp3, .avi, or any other
file type.

1.4 Objective

The objective of the Project is to allow users to download media files such as music, movies, and
games using a P2P software client that searches for other connected computers. The "peers" are
computer systems connected to each other through the Internet. Thus, the only requirements for a
computer to join peer-to-peer networks are an Internet connection and P2P software. The first
generation of P2P software is Napster, a central server-based model that was eventually shut

11

FTP|MINOR PROJECT

down.The second generation of P2P software is Gnutella and Kaza, which are user-based
models. BitTorrent became the third generation of P2P networks.

File transfers involve two computers, often designated as a client and a server and most
operations are for the copying files from one machine to another. Most WEB and FTP servers
are punished for being popular. Since all uploading is done from one central place, a popular site
needs more resources (CPU and bandwidth) to be able to cope. With the use of P2P, the clients
automatically mirror the files they download, easing the publisher's burden.
Peer to Peer File Sharing System allows peers to search, download and upload files to other
peers by just having the list of online clients from server. Peers manage on their own for
downloading files. A chat feature is also added so that they can chat with their friends.

1.5 Scope
You can configure computers in peer to peer workgroups to allow sharing of files, printers and
other resources across all of the devices. Peer networks allow data to be shared easily in both
directions, whether for downloads to your computer or uploads from your computer.

On the Internet, peer to peer networks handle a very high volume of file sharing traffic by
distributing the load across many computers. Because they do not rely exclusively on central
servers, P2P networks both scale better and are more resilient than client-server networks in case
of failures or traffic bottlenecks.
Peer to peer networking is common on small local area networks (LANs), particularly home
networks. Both wired and wireless home networks can be configured as peer to peer
environments.

Computers in a peer to peer network run the same networking protocols and software. Peer
networks are also often situated physically near to each other, typically in homes, small
businesses or schools. Some peer networks, however, utilize the Internet and are geographically
dispersed worldwide.

12

FTP|MINOR PROJECT

Features Of Project

There are several features of P2P file sharing system:

1. Creating Main P2P Server.


2. Creating Main P2P Client.
4. Manage online or offline user Lists in real time.
5. Sharing files on P2P Network.
6. Receive search request.
7. Search file on peers and sending results to other peer, who made search request.
8. Downloading File from other peer.
9. Uploading file to other.
10. Peers can change their Shared Path
11. Peers can chat and ask other peer to share files.
12. View Attached Peers.

13

FTP|MINOR PROJECT

HARDWARE & SOFTWARE REQUIREMENTS

3.1 INPUT REQUIREMENTS

The Point-to-Point sharing System will have a minimum set of following requirements:
3.1.1
3.1.2

3.1.3
3.1.4
3.1.5

Login: Whenever user tries to connect to the server it must provide a valid I.P address to
access the server. On the basis of server address either the user i.e. client system is
connected to the server or denied the access.
Online-clients: Once the client and server gets successfully connected the next thing that
is mandatory for the system is that server must show the list of the clients that are active
that time. It is important because some of the clients may be down so the user must not
keep accessing the offline clients.
Search: Once the online clients are displayed the interface must provide the facility to
search the file. Search file should have the functionality that it must indicate the paths of
all the system that have that file as specified by the user.
Selection: After listing the user should select one client that he/she finds the best and
enables downloading.
Downloading: While the downloading starts, progress bar keeps on indicating that the file
has been downloaded successfully or not.

3.2 OUTPUT REQUIREMENTS

The Point-to-Point sharing System has a minimum set of following output requirements:
3.2.1
3.2.2

Space: Downloading client must have surplus space at his\her HDD(C:\shared folder)
Message: Successful downloading of a particular file is indicated by a message at the
monitor screen of the downloading client.

14

FTP|MINOR PROJECT

3.3 SOFTWARE REQUIREMENTS


3.3.1
3.3.2

windows , LINUX , Macintosh


Java Virtual Machine

3.4 HARDWARE REQUIRMENTS


3.4.1
3.4.2
3.4.3

15

Pentium 4 Computer
256 MB RAM
High Speed Internet Connection(DSL/Cable)

FTP|MINOR PROJECT

Technologies TO Be Used
4.1 Multi-threading in Java

Nearly every operating system supports the concept of processes -- independently running
programs that are isolated from each other to some degree. Threading is a facility to allow
multiple activities to coexist within a single process. Most modern operating systems support
threads, and the concept of threads has been around in various forms for many years. Java is the
first mainstream programming language to explicitly include threading within the language itself,
rather than treating threading as a facility of the underlying operating system.

Like processes, threads are independent, concurrent paths of execution through a program, and
each thread has its own stack, its own program counter, and its own local variables. However,
threads within a process are less insulated from each other than separate processes are. They
share memory, file handles, and other per-process state. A process can support multiple threads,
which appear to execute simultaneously and asynchronously to each other. Multiple threads
within a process share the same memory address space, which means they have access to the
same variables and objects, and they allocate objects from the same heap. The Java thread
facility and API is deceptively simple. However, writing complex programs that use threading
effectively is not quite as simple. Because multiple threads coexist in the same memory space
and share the same variables, you must take care to ensure that your threads don't interfere with
each other. Multithreading enables you to write very efficient programs that make maximum use
of the CPU, because idle time can be kept to a minimum.
4.1.1

Benefits of using threads: The Java language includes a powerful threading facility built
into the language. The threading facility can be used to:
Increase the responsiveness of GUI applications
Take advantage of multiprocessor systems
Simplify program logic when there are multiple independent entities
Perform blocking I/O without blocking the entire program

When multiple threads execute byte-code instruction sequences in the same program, that action
is known as multithreading.
4.1.2

Life Cycle of a Thread : A thread goes through various stages in its life cycle. For
example, a thread is born, started, runs, and then dies. Following diagram shows
complete life cycle of a thread.

16

FTP|MINOR PROJECT

Figure 5.1: Life Cycle of Thread


4.2 THREADS USED :

ReceiveThread ->

It works on port 10000 and always runs in background. As it gets any file, it starts receiving
it.
SendThread ->

It works on port 25000 and whenever a sender receives a request to send a file or sender
wants to send a file by its own, the thread is invoked.

RequestReceiverThread ->

It works on port 30000 and whenever receiver sends a request i.e. clicks on "Download
File", the request is received by The Thread.

17

FTP|MINOR PROJECT

ChatThread ->

FileListSender ->

It works on port 10000 and whenever a chat message is sent by any sender, it is received
by the Thread and it displays the received message in chat-display area.

It is always ready to send the list of the files contained in shared folder(which sender sets
at beginning),it sends the files list on port 20000.

When a sender clicks on "Fetch Files List" button, the receiver sends request to sender
side at this port, and then thread is invoked at sender side which results in sending
complete files list to receiver, displayed in a dialog box to choose one file among the list.
The selected file is then displayed in text field and user requests to download a file.
4.3 Socket Programming

URLs and URL Connections provide a relatively high-level mechanism for accessing resources
on the Internet. Sometimes your programs require lower-level network communication, for
example, when you want to write a client-server application. In client-server applications, the
server provides some service, such as processing database queries or sending out current stock
prices. The client uses the service provided by the server, either displaying database query results
to the user or making stock purchase recommendations to an investor. The communication that
occurs between the client and the server must be reliable. That is, no data can be dropped and it
must arrive on the client side in the same order in which the server sent it.
TCP provides a reliable, point-to-point communication channel those client-server applications
on the Internet use to communicate with each other. To communicate over TCP, a client program
and a server program establish a connection to one another. Each program binds a socket to its
end of the connection. To communicate, the client and the server each reads from and writes to
the socket bound to the connection.

18

FTP|MINOR PROJECT

Figure 5.3 : Socket Programming


Syntax

// for tcp client side

Socket s= new Socket (InetAddress adr, int port);


//for server side

ServerSocket ss= new ServerSocket (InetAddress adr, int port);

4.3.1 Ports and Sockets

These entities lie at the heart of network communications. For anybody not already familiar with
the use of these terms in a network programming context, the two words very probably conjure
up images of hardware components.
Port: A port is a logical connection to a computer (as opposed to a physical connection) and is
identified by a number in the range 1-65535. This number has no correspondence with the
number of physical connections to the computer, of which there may be only one (even though
the number of ports used on that machine may be much greater than this).
Ports are implemented upon all computers attached to a network. Each port may be dedicated to
a particular server/service (though the number of available ports will normally greatly exceed the

19

FTP|MINOR PROJECT

number that is actually used). Port numbers in the range 1-1023 are normally set aside for the use
of specified standard services. For example, port 80 is normally used by Web servers for HTTP.

In most applications, of course, there are likely to be multiple clients wanting the same service at
the same time. A common example of this requirement is that of multiple browsers (quite
possibly thousands of them) wanting Web pages from the same server. The server, of course,
needs some way of distinguishing between clients and keeping their dialogues separate from
each other. This is achieved via the use of sockets.

Socket: Normally, a server runs on a specific computer and has a socket that is bound to a
specific port number. The server just waits, listening to the socket for a client to make a
connection request. A socket is one end-point of a two-way communication link between two
programs running on the network. Socket classes are used to represent the connection between a
client program and a server program. The java.net package provides two classes--Socket and
ServerSocket--that implement the client side of the connection and the server side of the
connection, respectively.
On the client-side: The client knows the hostname of the machine on which the server is
running and the port number on which the server is listening. To make a connection request, the
client tries to rendezvous with the server on the server's machine and port. The client also needs
to identify itself to the server so it binds to a local port number that it will use during this
connection. This is usually assigned by the system.

Figure 5.3.1 : Client side

If everything goes well, the server accepts the connection. Upon acceptance, the server gets a
new socket bound to the same local port and also has its remote endpoint set to the address and
port of the client. It needs a new socket so that it can continue to listen to the original socket for
connection requests while tending to the needs of the connected client.

20

FTP|MINOR PROJECT

Figure 5.3.1 : Server side


On the client side, if the connection is accepted, a socket is successfully created and the client
can use the socket to communicate with the server. The client and server can now communicate
by writing to or reading from their sockets.
The following steps occur when establishing a TCP connection between two computers using
sockets:

The server instantiates a ServerSocket object, denoting which port number


communication is to occur on.
The server invokes the accept() method of the ServerSocket class. This method waits
until a client connects to the server on the given port.
After the server is waiting, a client instantiates a Socket object, specifying the server
name and port number to connect to.
The constructor of the Socket class attempts to connect the client to the specified server
and port number. If communication is established, the client now has a Socket object
capable of communicating with the server.
On the server side, the accept() method returns a reference to a new socket on the server
that is connected to the client's socket.

4.2 NETWORKING IN JAVA


The Internet is composed of millions of computers, located all across the globe; each of these
computers will have a unique IP address. IP addresses are 32-bit numbers, containing four octets
(8 bit numbers) separated by a full stop. Each computer with a direct internet connection will
have a unique IP address, (e.g. 207.68.156.61). Some computers have temporary addresses, such
as when you connect to your ISP through a modem. Others have permanent addresses, and some
even have their own unique domain names (e.g. www.microsoft.com).For example, most web
servers use port 80. Of course, you can use any port you like theres no rule that says you must
use 80.

21

FTP|MINOR PROJECT

Figure 5.4: Ports help computers to identify which service data is for
4.2.1

Advantages of Networking

Networking has a lot of advantages over traditional advertising and marketing. These are the
most important advantages:
More business : As you develop networking skills and contacts, youll find that the
amount of work you get from referrals accounts for the largest part of your new business.
And the most profitable.
Better business : The business you get from referrals will usually be from happy
customers. This will mean that your best customers, those who pay on time and without
headaches, will be the ones who send you the additional business.
Cost savings : As you get more business through referrals, youll find less and less need
to advertise and market your business. This means less of the associated costs. And since
youll be getting better quality business, it means less bad debts.

P2P ARCHITECTURE

22

FTP|MINOR PROJECT

6.1 Features

Figure 9.2.1 P2P Architecture

All nodes are both clients and servers


Provide and consume data
Any node can initiate a connection
No centralized data source
The ultimate form of democracy on the Internet

6.2 P2P Network Characteristics

Clients are also servers and routers


Nodes contribute content, storage, memory, CPU
Nodes are autonomous (no administrative authority)
Network is dynamic: nodes enter and leave the network frequently
Nodes collaborate directly with each other (not through well-known servers)
Nodes have widely varying capabilities

23

FTP|MINOR PROJECT

FLOW CHART OF OPERATION

Above flow chart represents the file transfer process.

24

FTP|MINOR PROJECT

Flow chart to receive a file.

25

FTP|MINOR PROJECT

Flow chart to perform chat activity

26

FTP|MINOR PROJECT

Flow chart of entire system

27

FTP|MINOR PROJECT

CODE
FileListSender.java
package p2p;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
public class FileListSender {
static ServerSocket ss;
static Socket s;
static byte[] b=" ".getBytes();
static InputStream in;
static OutputStream out;
public FileListSender(Socket s,String fname) throws IOException{
in=s.getInputStream();
out=s.getOutputStream();
while(!"end".equals(fname)){
File f=new File(fname);

28

FTP|MINOR PROJECT

if(f.isDirectory())
showContent(fname);
else
send(fname);
send("exit0");
System.out.println("files sent.");
fname="end";
}
}
public void showContent(String fname) throws IOException{
File f=new File(fname);
String[] allfiles=f.list();
for(String name : allfiles){
f=new File(fname+"\\"+name);
if(f.isDirectory()){
showContent(f.getAbsolutePath());
}
else
send(f.getName()+"->"+f.getAbsolutePath());
}
}
public void send(String fname) throws IOException{
b=(fname+" \n").getBytes();
System.out.println(fname);
out.write(b);
out.flush();
}
}

29

FTP|MINOR PROJECT

FetchList.java
package p2p;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Vector;

public class fetchList {


Vector v =new Vector();
public fetchList(InetAddress ip) throws IOException{
int port = 20000;
Socket s = new Socket(ip,port);
InputStream in= s.getInputStream();
byte[] b=" ".getBytes();
boolean status=true;
String result="";
while(status){
in.read(b);
String tmp=new String(b);
result=result+tmp;

30

FTP|MINOR PROJECT

if(result.contains(" \n")){
v.add(result.trim());
result="";
}
if(result.contains("exit0")){
status=false;
}
}
System.out.println("exit work");
}
public Object[] list(){
Object[] files= v.toArray();
System.out.println(files[0].toString()+files[1].toString());

return files;
}
}

31

FTP|MINOR PROJECT

FRAME1.JAVA
package p2p;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

public class frame1 extends javax.swing.JFrame {


/**
* Creates new form frame1
*/
class MyThread extends Thread{

32

FTP|MINOR PROJECT

public MyThread() throws IOException{


super("Client Thread");
}
@Override
public void run(){
try {
InetAddress ip = InetAddress.getByName("192.168.140.1");
Socket s = new Socket(ip,12345);
s.close();
ServerSocket ss= new ServerSocket(54321);
s=ss.accept();
while(s.isConnected()){
System.out.println("Client 1 started."+s.getLocalPort());
InputStream in =s.getInputStream();

int count=0;
byte[] b= new byte[100];
File f = new File("ips.txt");
f.delete();

33

FileOutputStream fos=new FileOutputStream(f,true);

FTP|MINOR PROJECT

BufferedOutputStream bos=new BufferedOutputStream(fos);


while(in.read(b)!=(-1)){
System.out.println(s.isConnected());
bos.write(b);
bos.flush();
count++;
}
System.out.println(count);
bos.close();
fos.close();
s.close();
s=ss.accept();
}
} catch (UnknownHostException ex) {
Logger.getLogger(frame1.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(frame1.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public frame1() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.

34

FTP|MINOR PROJECT

* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jMenuBar2 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMaximumSize(new java.awt.Dimension(554, 490));
setMinimumSize(new java.awt.Dimension(554, 495));
setPreferredSize(new java.awt.Dimension(490, 462));
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}

35

FTP|MINOR PROJECT

});
getContentPane().setLayout(null);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel3.setForeground(new java.awt.Color(51, 51, 0));
jLabel3.setText("Welcome to file sharing system");
getContentPane().add(jLabel3);
jLabel3.setBounds(60, 30, 400, 48);
jLabel5.setForeground(new java.awt.Color(51, 51, 0));
jLabel5.setText("System IP :");
getContentPane().add(jLabel5);
jLabel5.setBounds(30, 100, 80, 20);
jTextField1.setEditable(false);
getContentPane().add(jTextField1);
jTextField1.setBounds(100, 100, 120, 20);
jLabel1.setForeground(new java.awt.Color(51, 51, 0));
jLabel1.setText("Other Information :");
getContentPane().add(jLabel1);
jLabel1.setBounds(30, 130, 130, 40);
jScrollPane1.setOpaque(false);
jTextArea1.setEditable(false);
jTextArea1.setColumns(20);
jTextArea1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

36

FTP|MINOR PROJECT

jTextArea1.setRows(5);
jTextArea1.setOpaque(false);
jScrollPane1.setViewportView(jTextArea1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(20, 170, 450, 250);
jButton1.setText("Proceed");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(280, 120, 120, 23);
jMenu1.setText("Menu");
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
});
jMenuItem1.setText("Help");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}

37

FTP|MINOR PROJECT

});
jMenu1.add(jMenuItem1);
jMenuItem3.setText("About");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);
jMenuBar2.add(jMenu1);
setJMenuBar(jMenuBar2);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
MyThread t = new MyThread();
t.start();
frame2 f = new frame2();
f.setVisible(true);
} catch (IOException ex) {
Logger.getLogger(frame1.class.getName()).log(Level.SEVERE, null, ex);
}

38

FTP|MINOR PROJECT

// f.setserverIP(serverIP);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {

// TODO add your handling code here:

try {
jTextField1.setText(InetAddress.getLocalHost().toString());
} catch (UnknownHostException ex) {
Logger.getLogger(frame1.class.getName()).log(Level.SEVERE, null, ex);
}

Properties properties = System.getProperties();


Set<Object> keys = properties.keySet();
for(Object key : keys){
jTextArea1.append(properties.get(key)+"\n");
// System.out.println(key + ": " + properties.get(key));
}
jTextArea1.append("\nAvailable processors (cores) -> " + Runtime.getRuntime().availableProcessors());
jTextArea1.append("\nFree memory (bytes) -> " + Runtime.getRuntime().freeMemory());
/*

} catch (UnknownHostException ex) {

39

FTP|MINOR PROJECT

Logger.getLogger(frame1.class.getName()).log(Level.SEVERE, null, ex);


}
*/
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
new frame3().setVisible(true);
}
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
new frame4().setVisible(true);
}
public static void main(String[] args) {
new frame1().setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar2;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
}

40

FTP|MINOR PROJECT

FRAME2.java
package p2p;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

public class frame2 extends javax.swing.JFrame {


/**

41

FTP|MINOR PROJECT

* Creates new form frame2


*/
DefaultTableModel model;
class ChatThread extends Thread{
public ChatThread() throws IOException{
super("Client Thread");
}
@Override
public void run(){
try {
ServerSocket css = new ServerSocket(10000);
Socket s=css.accept();
while(s.isConnected()){
System.out.println("chatThread");
byte[] b=" ".getBytes();
InputStream in=s.getInputStream();
OutputStream out=s.getOutputStream();
boolean status=true;
String result="";
while(status){

42

in.read(b);

FTP|MINOR PROJECT

String tmp=new String(b);


result=result+tmp;
if(result.contains(" \n")){
System.out.println(result.trim());
setMessage(result.trim());
result="";
status=false;
}
}
s.close();
s=css.accept();
} } catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
class FileListThread extends Thread{
public FileListThread() throws IOException{
super("Client Thread");
}
@Override

43

FTP|MINOR PROJECT

public void run(){


try {
ServerSocket flss = new ServerSocket(20000);
Socket s=flss.accept();
while(s.isConnected()){
System.out.println("flsthread");
FileListSender fs=new FileListSender(s,jTextField2.getText());
s.close();
s=flss.accept();
} } catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
class RecieveThread extends Thread{
public RecieveThread() throws IOException{
super("Client Thread");
}
@Override
public void run(){
System.out.println("rcvThread");
try {

44

FTP|MINOR PROJECT

ServerSocket rs = new ServerSocket(25000);


String fname = null;
Socket s=rs.accept();
System.out.println(s.isConnected());
while(s.isConnected()){

byte[] b=" ".getBytes();


InputStream in=s.getInputStream();
OutputStream out=s.getOutputStream();
boolean status=true;
String result="";
while(status){
in.read(b);
String tmp=new String(b);
result=result+tmp;
if(result.contains(" \n")){
fname =result.trim();
status=false;
}
}
//

45

s.close();

FTP|MINOR PROJECT

//

s=rs.accept();
JOptionPane.showMessageDialog(null,"Requested File is going to be recieved.");
File f = new File(fname);
System.out.println(f.getName());
File nf = new File(jTextField3.getText(),f.getName());
System.out.println(nf.getPath());
FileOutputStream fos = new FileOutputStream(nf,true);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int count=0;
b = new byte[100];

//

in=s.getInputStream();
while((in.read(b))!=(-1)){
bos.write(b);
bos.flush();
count++;
}
s.close();
bos.close();
fos.close();
System.out.println("No.of times"+count);
JOptionPane.showMessageDialog(null,"File downloaded successfully.");
s=rs.accept();
}

} catch (IOException ex) {

46

FTP|MINOR PROJECT

Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);


}
}
}
class RqstRcvrThread extends Thread{
public RqstRcvrThread() throws IOException{
super("Client Thread");
}
@Override
public void run(){
try {
ServerSocket rrss = new ServerSocket(30000);
Socket s=rrss.accept();
while(s.isConnected()){
System.out.println("rrthred");
byte[] b=" ".getBytes();
InputStream in=s.getInputStream();
OutputStream out=s.getOutputStream();
boolean status=true;
String result="";
while(status){
in.read(b);

47

FTP|MINOR PROJECT

String tmp=new String(b);


result=result+tmp;
if(result.contains(" \n")){
status=false;
break;
}
}
result=result.trim().split(" \n")[0];
System.out.println(result);
int ret=JOptionPane.showConfirmDialog(null,s.getInetAddress()+"wants to download file :"+result+
". Would you allow file transfer ?");
SendThread st = new SendThread(s.getInetAddress(),result);
st.start();
s.close();
s=rrss.accept();
} } catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
}

48

FTP|MINOR PROJECT

class SendThread extends Thread{


InetAddress ip ;
String fname;
public SendThread(InetAddress ip,String name) throws IOException{
super("Client Thread");
this.ip=ip;
fname = name;
}
@Override
public void run(){
try {
System.out.println("sendThread");
byte[] b=(fname+" \n").getBytes();
Socket s=new Socket(ip,25000);
if(s.isConnected())
System.out.println("connect");
OutputStream out = s.getOutputStream();
out.write(b);
out.flush();
//

s.close();
System.out.println("send File");

//

s = new Socket(ip,50000);
FileInputStream fis=new FileInputStream(fname);

49

BufferedInputStream bis=new BufferedInputStream(fis);

FTP|MINOR PROJECT

int count=0;
//

while(s.isConnected()){
//

out=s.getOutputStream();
b=new byte[100];
while ((bis.read(b)) != -1){
out.write(b);
out.flush();
count++;
}
System.out.println(count);
s.close();
bis.close();
fis.close();

//

}
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}

}
}

public void setMessage(String str){


jTextArea1.append(str+"\n");
}
public frame2() throws IOException {

50

FTP|MINOR PROJECT

initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jFileChooser1 = new javax.swing.JFileChooser();
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton3 = new javax.swing.JRadioButton();
jLabel3 = new javax.swing.JLabel();
jRadioButton4 = new javax.swing.JRadioButton();
jRadioButton5 = new javax.swing.JRadioButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();

51

FTP|MINOR PROJECT

jScrollPane2 = new javax.swing.JScrollPane();


jTextArea1 = new javax.swing.JTextArea();
jSeparator1 = new javax.swing.JSeparator();
jScrollPane1 = new javax.swing.JScrollPane();
DefaultTableModel model = new DefaultTableModel();
jTable1 = new javax.swing.JTable(model);
jTextField2 = new javax.swing.JTextField();
jButton6 = new javax.swing.JButton();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setMinimumSize(new java.awt.Dimension(775, 635));
setPreferredSize(new java.awt.Dimension(775, 635));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
getContentPane().setLayout(null);
jTextField1.setText("//message");

52

FTP|MINOR PROJECT

getContentPane().add(jTextField1);
jTextField1.setBounds(50, 530, 228, 30);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(51, 51, 0));
jLabel1.setText("Chat Window");
getContentPane().add(jLabel1);
jLabel1.setBounds(130, 320, 135, 17);
jButton1.setText("send");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(280, 530, 70, 30);
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setText("select sender or receiver mode");
jLabel2.setPreferredSize(new java.awt.Dimension(77, 15));
getContentPane().add(jLabel2);
jLabel2.setBounds(470, 120, 220, 15);
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("Send");
jRadioButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {

53

FTP|MINOR PROJECT

jRadioButton2MouseClicked(evt);
}
});
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
getContentPane().add(jRadioButton2);
jRadioButton2.setBounds(600, 150, 80, 23);
buttonGroup1.add(jRadioButton3);
jRadioButton3.setText("Receive");
jRadioButton3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jRadioButton3MouseClicked(evt);
}
});
jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton3ActionPerformed(evt);
}
});
getContentPane().add(jRadioButton3);
jRadioButton3.setBounds(470, 150, 93, 23);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setText("select an user to send a message");

54

FTP|MINOR PROJECT

getContentPane().add(jLabel3);
jLabel3.setBounds(60, 40, 280, 21);
buttonGroup2.add(jRadioButton4);
jRadioButton4.setText("single user");
jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton4ActionPerformed(evt);
}
});
getContentPane().add(jRadioButton4);
jRadioButton4.setBounds(60, 10, 113, 23);
buttonGroup2.add(jRadioButton5);
jRadioButton5.setText("broadcast message");
jRadioButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton5ActionPerformed(evt);
}
});
getContentPane().add(jRadioButton5);
jRadioButton5.setBounds(170, 10, 170, 20);
jButton2.setText("Download File");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}

55

FTP|MINOR PROJECT

});
getContentPane().add(jButton2);
jButton2.setBounds(500, 370, 120, 23);
jButton3.setText("Fetch File List");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3);
jButton3.setBounds(470, 270, 180, 23);
jButton4.setText("set the download folder");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4);
jButton4.setBounds(460, 180, 210, 23);
jTextArea1.setEditable(false);
jTextArea1.setBackground(new java.awt.Color(204, 204, 204));
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane2.setViewportView(jTextArea1);

56

FTP|MINOR PROJECT

getContentPane().add(jScrollPane2);
jScrollPane2.setBounds(50, 350, 300, 180);
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
getContentPane().add(jSeparator1);
jSeparator1.setBounds(390, 100, 20, 350);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"user name", "user ip"
}
));
jTable1.setPreferredSize(new java.awt.Dimension(500, 400));
jScrollPane1.setViewportView(jTable1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(50, 80, 300, 220);
jTextField2.setText("//complete path here");
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
getContentPane().add(jTextField2);

57

FTP|MINOR PROJECT

jTextField2.setBounds(430, 240, 290, 20);


jButton6.setText("Set shared Folder path");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
getContentPane().add(jButton6);
jButton6.setBounds(460, 200, 210, 23);
jTextField3.setText("jTextField3");
getContentPane().add(jTextField3);
jTextField3.setBounds(430, 220, 290, 20);
jTextField4.setText("//fetched file name");
getContentPane().add(jTextField4);
jTextField4.setBounds(440, 320, 280, 20);
jButton7.setText("Select File");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
getContentPane().add(jButton7);
jButton7.setBounds(500, 290, 110, 23);

58

FTP|MINOR PROJECT

jButton8.setText("Send File");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
getContentPane().add(jButton8);
jButton8.setBounds(500, 350, 120, 23);
pack();
}// </editor-fold>
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try {
InetAddress ip = InetAddress.getByName((model.getValueAt(jTable1.getSelectedRow(),0)).toString());
String str = jTextField4.getText();
//

String fname=str;
String fname=str.split("->")[1];
System.out.println(fname);
byte[] b=(fname+" \n").getBytes();
Socket s = new Socket(ip,30000);
OutputStream out = s.getOutputStream();
out.write(b);
out.flush();

59

FTP|MINOR PROJECT

s.close();
} catch (UnknownHostException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
jButton2.setVisible(false);
jTextField4.setVisible(false);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
// TODO add your handling code here:
InetAddress ip = InetAddress.getByName((model.getValueAt(jTable1.getSelectedRow(),0)).toString());
// int port = Integer.parseInt((model.getValueAt(jTable1.getSelectedRow(),2)).toString());
int port=10000;

Socket s = new Socket(ip,port);


String msg = s.getLocalAddress().getHostName()+"->"+jTextField1.getText().trim()+" \n";
byte[] b=msg.getBytes();
System.out.println(msg);
//

byte[] b=(jTextField1.getText().trim()+" \n").getBytes();


System.out.println(s.getLocalPort());
OutputStream out=s.getOutputStream();

60

FTP|MINOR PROJECT

out.write(b);
out.flush();
if(!jTextField1.getText().trim().contains("exit0")){
jTextArea1.append(msg);
}
jTextField1.setText("");
s.close();
} catch (UnknownHostException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}

}
private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jTable1.setRowSelectionAllowed(false);
}
private void jRadioButton3MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(jRadioButton3.isSelected()){
jButton6.setVisible(false);

61

FTP|MINOR PROJECT

jButton7.setVisible(false);
jTextField2.setVisible(false);
jButton3.setVisible(true);
jButton4.setVisible(true);
jTextField3.setVisible(true);
}
}
private void jRadioButton2MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(jRadioButton2.isSelected()){
jButton3.setVisible(false);
jButton4.setVisible(false);
jTextField3.setVisible(false);
jButton6.setVisible(true);
jButton7.setVisible(true);
jTextField2.setVisible(true);
}
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:

62

FTP|MINOR PROJECT

try {
ChatThread ct = new ChatThread();
ct.start();
FileListThread flt = new FileListThread();
flt.start();
RqstRcvrThread rrt = new RqstRcvrThread();
rrt.start();
RecieveThread rt = new RecieveThread();
rt.start();
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
jButton2.setVisible(false);
jButton3.setVisible(false);
jButton4.setVisible(false);
jButton6.setVisible(false);
jButton7.setVisible(false);
jButton8.setVisible(false);
jTextField2.setVisible(false);
jTextField3.setVisible(false);
jTextField4.setVisible(false);
jRadioButton4.setSelected(true);
}
private void formWindowActivated(java.awt.event.WindowEvent evt) {
FileReader fr= null;

63

FTP|MINOR PROJECT

try {
File f= new File("ips.txt");
System.out.println(f.getAbsolutePath());
fr = new FileReader(f);
BufferedReader br= new BufferedReader(fr);
String s;

while((s=br.readLine())!=null){
if(!"".equals(s.trim())){
model=(DefaultTableModel) jTable1.getModel();
model.addRow(s.split(":"));
}
}
} catch (FileNotFoundException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
fr.close();
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

64

FTP|MINOR PROJECT

private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
jTable1.setRowSelectionAllowed(true);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String name=null;
JFileChooser fc= new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setAcceptAllFileFilterUsed(false);
int ret = fc.showOpenDialog(this);
if (ret== JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();
name= file.getAbsolutePath();
}
String sharedpath=name;
jTextField2.setText(sharedpath);
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

65

FTP|MINOR PROJECT

// TODO add your handling code here:


Object[] bigList = null;
try {
InetAddress ip = InetAddress.getByName((model.getValueAt(jTable1.getSelectedRow(),0)).toString());
fetchList list = new fetchList(ip);
bigList = list.list();
} catch (UnknownHostException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}

String selectedfile = (String)


JOptionPane.QUESTION_MESSAGE,

JOptionPane.showInputDialog(this,

"Select

file",

"Input",

null, bigList,"Done");
jTextField4.setText(selectedfile);
jTextField4.setVisible(true);
jButton2.setVisible(true);
}
private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

66

FTP|MINOR PROJECT

private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {


}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String name=null;
JFileChooser fc= new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setAcceptAllFileFilterUsed(false);
int ret = fc.showOpenDialog(this);
if (ret== JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();
name= file.getAbsolutePath();
}
jTextField3.setText(name);
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String name=null;
JFileChooser fc= new JFileChooser();
int ret = fc.showOpenDialog(this);
if (ret== JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();

67

FTP|MINOR PROJECT

name= file.getAbsolutePath();
}
jTextField4.setText(name);
jTextField4.setVisible(true);
jButton8.setVisible(true);
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
InetAddress ip;
try {
ip = InetAddress.getByName( model.getValueAt(jTable1.getSelectedRow(),0).toString());
SendThread st = new SendThread(ip,jTextField4.getText());
st.start();
} catch (UnknownHostException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(frame2.class.getName()).log(Level.SEVERE, null, ex);
}
jTextField4.setVisible(false);
jButton8.setVisible(false);
}
public static void main(String[] args) throws IOException {
new frame2().setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;

68

FTP|MINOR PROJECT

private javax.swing.JButton jButton3;


private javax.swing.JButton jButton4;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JRadioButton jRadioButton5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTable jTable1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
// End of variables declaration
}

69

FTP|MINOR PROJECT

FRAME3.java
package p2p;
public class frame3 extends javax.swing.JFrame {
/**
* Creates new form frame3
*/
public frame3() {
initComponents();
this.pack();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
textArea1 = new java.awt.TextArea();
jLabel1 = new javax.swing.JLabel();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jLabel2 = new javax.swing.JLabel();

70

FTP|MINOR PROJECT

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(589, 415));
setPreferredSize(new java.awt.Dimension(600, 450));
getContentPane().setLayout(null);
textArea1.setMinimumSize(new java.awt.Dimension(80, 80));
getContentPane().add(textArea1);
textArea1.setBounds(170, 70, 410, 320);
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Application Guide Book");
getContentPane().add(jLabel1);
jLabel1.setBounds(100, 30, 330, 30);
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("Request a file ?");
getContentPane().add(jRadioButton1);
jRadioButton1.setBounds(40, 230, 130, 23);
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("Send a file ?");
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}

71

FTP|MINOR PROJECT

});
getContentPane().add(jRadioButton2);
jRadioButton2.setBounds(40, 200, 110, 23);
jLabel2.setText("How to :");
getContentPane().add(jLabel2);
jLabel2.setBounds(40, 160, 50, 14);
pack();
}// </editor-fold>
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private java.awt.TextArea textArea1;
// End of variables declaration
}

72

FTP|MINOR PROJECT

FRAME4.java
package p2p;
public class frame4 extends javax.swing.JFrame {
public frame4() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();

73

FTP|MINOR PROJECT

jSeparator2 = new javax.swing.JSeparator();


setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBounds(new java.awt.Rectangle(0, 0, 0, 0));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setMinimumSize(new java.awt.Dimension(589, 410));
setPreferredSize(new java.awt.Dimension(600, 450));
getContentPane().setLayout(null);
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("About ");
getContentPane().add(jLabel1);
jLabel1.setBounds(230, 20, 120, 30);
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setText("Project Coordinator");
getContentPane().add(jLabel2);
jLabel2.setBounds(70, 120, 140, 20);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setText("Project Guide");
getContentPane().add(jLabel3);
jLabel3.setBounds(390, 120, 120, 20);
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel4.setText("Shweta Jain");

74

FTP|MINOR PROJECT

getContentPane().add(jLabel4);
jLabel4.setBounds(70, 140, 120, 40);
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel5.setText("Dr. Praveen Kaushik");
getContentPane().add(jLabel5);
jLabel5.setBounds(360, 140, 190, 40);
jLabel6.setText("Designed and Developed by :");
getContentPane().add(jLabel6);
jLabel6.setBounds(230, 310, 180, 14);
jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel7.setText("Anurodh Tripathi 131112030");
getContentPane().add(jLabel7);
jLabel7.setBounds(70, 350, 190, 17);
jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel8.setText("Ajeet Pandey

131112034");

getContentPane().add(jLabel8);
jLabel8.setBounds(70, 370, 190, 17);
jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel9.setText("131112032 Jitendra Gupta ");
getContentPane().add(jLabel9);
jLabel9.setBounds(330, 350, 173, 17);
jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

75

FTP|MINOR PROJECT

jLabel10.setText("131112041 Shweta Gupta");


getContentPane().add(jLabel10);
jLabel10.setBounds(330, 370, 166, 20);
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
getContentPane().add(jSeparator1);
jSeparator1.setBounds(290, 80, 20, 160);
jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
getContentPane().add(jSeparator2);
jSeparator2.setBounds(290, 340, 20, 60);
pack();
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
// End of variables declaration

76

FTP|MINOR PROJECT

SPLASH.java
package p2p;
public class splash extends javax.swing.JPanel {
public splash() {
initComponents();
}
public void abc(int a){
jProgressBar2.setValue(a);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jProgressBar2 = new javax.swing.JProgressBar();
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/img2.jpg"))); // NOI18N
jLabel1.setMaximumSize(new java.awt.Dimension(1300, 700));
jLabel1.setMinimumSize(new java.awt.Dimension(1360, 700));
jProgressBar2.setForeground(new java.awt.Color(153, 102, 255));

77

FTP|MINOR PROJECT

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);


this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jProgressBar2,
Short.MAX_VALUE)))

javax.swing.GroupLayout.DEFAULT_SIZE,

755,

);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

447,

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jProgressBar2,
javax.swing.GroupLayout.PREFERRED_SIZE))

javax.swing.GroupLayout.PREFERRED_SIZE,

22,

);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JProgressBar jProgressBar2;
// End of variables declaration
}

78

FTP|MINOR PROJECT

TESTING AND EXECUTION OF THE APPLICATION

LOADING PROJECT

79

FTP|MINOR PROJECT

ABOUT PROJECT

80

FTP|MINOR PROJECT

HOME PAGE

81

FTP|MINOR PROJECT

Operational Window

82

FTP|MINOR PROJECT

MAIN SERVER (Only main server runs this frame)

83

FTP|MINOR PROJECT

RECEIVER OPTIONS (when client choses itself as Reciever)

84

FTP|MINOR PROJECT

SENDER OPTIONS(when client choses itself as Sender)

85

FTP|MINOR PROJECT

File Chooser (when client wants to select file or folder)

FETCHED FILE LIST(when receiver client fetches shared folder details from sender client)

86

FTP|MINOR PROJECT

SENDER GIVE PERMISSION TO DOWNLOAD FILE

FILE RECEIVE NOTIFICATION (when client is about to receive File)

FILE DOWNLOAD SUCCESSFUL (on completion of file download, dialog opens at receiver
side)

87

FTP|MINOR PROJECT

Security Analysis
What risks does file-sharing technology introduce?

Installation of malicious code - When you use P2P applications, it is difficult, if not
impossible, to verify that the source of the files is trustworthy. These applications are
often used by attackers to transmit malicious code. Attackers may incorporate spyware,
viruses, Trojan horses, or worms into the files. When you download the files, your
computer becomes infected (see Recognizing and Avoiding Spyware and Recovering from
Viruses, Worms, and Trojan Horses for more information).
Exposure of sensitive or personal information - By using P2P applications, you may be
giving other users access to personal information. Whether it's because certain directories
are accessible or because you provide personal information to what you believe to be a
trusted person or organization, unauthorized people may be able to access your financial
or medical data, personal documents, sensitive corporate information, or other personal
information. Once information has been exposed to unauthorized people, it's difficult to
know how many people have accessed it. The availability of this information may increase
your risk of identity theft (see Protecting Your Privacy and Avoiding Social Engineering and
Phishing Attacks for more information).
Susceptibility to attack - Some P2P applications may ask you to open certain ports on
your firewall to transmit the files. However, opening some of these ports may give
attackers access to your computer or enable them to attack your computer by taking
advantage of any vulnerabilities that may exist in the P2P application. There are some P2P
applications that can modify and penetrate firewalls themselves, without your knowledge.
Denial of service - Downloading files causes a significant amount of traffic over the
network. This activity may reduce the availability of certain programs on your computer or
may limit your access to the internet (see Understanding Denial-of-Service Attacks for
more information).
Prosecution - Files shared through P2P applications may include pirated software,
copyrighted material, or pornography. If you download these, even unknowingly, you may
be faced with fines or other legal action. If your computer is on a company network and
exposes customer information, both you and your company may be liable.

How can you minimize these risks?


The best way to eliminate these risks is to avoid using P2P applications. However, if you choose
to use this technology, you can follow some good security practices to minimize your risk:

88

FTP|MINOR PROJECT

use and maintain anti-virus software - Anti-virus software recognizes and protects
your computer against most known viruses. However, attackers are continually writing
new viruses, so it is important to keep your anti-virus software current
(see Understanding Anti-Virus Software for more information).
install or enable a firewall - Firewalls may be able to prevent some types of infection
by blocking malicious traffic before it can enter your computer (see Understanding
Firewalls for more information). Some operating systems actually include a firewall, but
you need to make sure it is enabled

Restricted Access
For some FTP servers, it is desirable to restrict access based on network address. For example,
a server might want to restrict access to certain files from certain places (e.g., a certain file
should not be transferred out of an organization). In such a situation, the server should
confirm that the network address of the remote hosts on both the control connection and the
data connection are within the organization before sending a restricted file. By checking both
connections, a server is protected against the case when the control connection is established
with a trusted host and the data connection is not. Likewise, the client should verify the IP
address of the remote host after accepting a connection on a port opened in listen mode to
verify that the connection was made by the expected server. Note that restricting access based
on network address leaves the FTP server vulnerable to "spoof" attacks. In a spoof attack, for
example, an attacking machine could assume the host address of another machine inside an
organization and download files that are not accessible from outside the organization.

Protecting Passwords
To minimize the risk of brute force password guessing through the FTP server, it is suggested
that servers limit the number of attempts that can be made at sending a correct password.
After a small number of attempts (3-5), the server should close the control connection with the
client. Before closing the control connection the server must send a return code of 421
("Service not available, closing control connection.. In addition, it is suggested that the server
impose a 5 second delay before replying to an invalid "PASS" command to diminish the
efficiency of a brute force attack. If available, mechanisms already provided by the target
operating system should be used to implement the above suggestions. An intruder can subvert
the above mechanisms by establishing multiple, parallel control connections to a server. To

89

FTP|MINOR PROJECT

combat the use of multiple concurrent connections, the server could either limit the total
number of control connections possible or attempt to detect suspicious activity across sessions
and refuse further connections from the site. However, both of these mechanisms open the
door to "denial of service" attacks, in which an attacker purposely initiate the attack to disable
access by a valid user.
Standard FTP sends passwords in clear text using the "PASS" command. It is suggested that
FTP clients and servers use alternate authentication mechanisms that are not subject to
eavesdropping (such as the mechanisms being developed by the IETF Common Authentication
Technology Working Group ).

Privacy
All data and control information (including passwords) is sent across the network in
unencrypted form by standard FTP .To guarantee the privacy of the information FTP transmits,
a strong encryption scheme should be used whenever possible.

Protecting Usernames
Standard FTP specifies a 530 response to the USER command when the username is rejected.
If the username is valid and a password is required FTP returns a 331 response instead. In
order to prevent a malicious client from determining valid usernames on a server, it is
suggested that a server always return 331 to the USER command and then reject the
combination of username and password for an invalid username.

Port Stealing
Many operating systems assign dynamic port numbers in increasing order. By making a
legitimate transfer, an attacker can observe the current port number allocated by the server
and "guess" the next one that will be used. The attacker can make a connection to this port,
thus denying another legitimate client the ability to make a transfer. Alternatively, the

90

FTP|MINOR PROJECT

attacker can steal a file meant for a legitimate user. In addition, an attacker can insert a
forged file into a data stream thought to come from an authenticated client. This problem
can be mitigated by making FTP clients and servers use random local port numbers for data
connections, either by requesting random ports from the operating system or using system
dependent mechanisms.

Software-Base Security Problems

The emphasis in this document is on protocol-related security issues. There are a number of
documented FTP security-related problems that are due to poor implementation as well.
Although the details of these types of problems are beyond the scope of this document, it
should be pointed out that the following FTP features has been abused in the past and should
be treated with great care by future implementers:
Anonymous FTP
Anonymous FTP refers to the ability of a client to connect to an FTP server with minimal
authentication and gain access to public files. Security problems arise when such a user can
read all files on the system or can create files.
Remote Command Execution
An optional FTP extension, "SITE EXEC", allows clients to execute arbitrary commands on the
server. This feature should obviously
be implemented with great care. There are several
documented cases of the FTP "SITE EXEC" command being used to subvert server security
Debug Code
Several previous security compromises related to FTP can be attributed to software that was
installed with debugging features enabled .

91

FTP|MINOR PROJECT

FUTURE OF PROJECT
1. Resuming Broken Downloads

When downloading large files, the download can break or be interrupted. This means that you
need to start all over to download it, which can be a real hassle for large files, or slow
connections. When we will download the files in parts, it will reduce traffic congestion on
network.
2. Virus Scanning of files before they are downloaded

If you frequently download files from suspicious peers, its probably worth it to check for viruses
before you download, instead of waiting to see if your regular anti-virus software will catch it
after you download.
3. Video Conferencing And Audio Casting

The impact of video and audio web sites on the Internet has been very large over the last couple
of years - and will only increase. Therefore there has been talk of moving video streaming to P2P
networks, to lessen the load on the Internet. A P2P approach for video streaming would be to
hold a copy of a file in different parts of the world and serve it from multiple points to users.
4. Mobile P2P Applications

Many popular web applications have been ported to mobile platforms already. Likewise there is
huge potential for P2P mobile applications, at least when wireless network enabled mobile
phones become more popular. I think it will follow the same trend as for PC P2P applications i.e. it will start from instant messaging, followed by file-sharing and IP telephony, then video and
other media.
5. E-commerce

Consumer to Consumer e-commerce is one of the most popular services on the Internet. A
centralized trading platform (such as eBay) enables consumers to trade, buy or sell their goods.
However in a centralized system, there is always a possibility of a failure - such as the server
goes down or is busy. P2P enabled e-commerce can remove the centralized system and so lessen
the possibility of failures. However there are many things that have to be implemented for a P2P
system for e-commerce to work - it has to be secure, transactional and workflow-based to track
different stages of the sales process Page | 144

92

FTP|MINOR PROJECT

REFERENCES

The following links, websites and study materials helped us in understanding the technical
aspects of the project and made our project a reality.

1.

Links for studying concept of P2P.


http://cs.berry.edu/~nhamid/p2p/
http://tutorials.jenkov.com/p2p/index.html

2.

To acquire subject knowledge and using content for theoretical inclusion.


https://en.wikipedia.org/

http://www.heatonresearch.com/book/programming-neural-networks-java-2.html

3.

To learn concepts of FTP.

4.

Implementation concept

http://www.cse.wustl.edu/~jain/cse571-07/ftp/p2p/
http://www.academia.edu/3276312/Peer-tohttp://p2peducation.pbworks.com/w/page/8897427/FrontPage
http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4063779&tag=1

http://www.javaworld.com/article/2071877/enterprise-java/peer-to-peer-applicationsmade-easy.html
https://www.scribd.com/doc/103929820/Peer2Peer-File-Sharing-System-With-ChatUsing-Java
https://jxta.kenai.com/

http://www.webreference.com/xml/column32/index.html
http://archive.oreilly.com/topics/java/P2P_Java

93

FTP|MINOR PROJECT

Appendix
Abstraction: Abstraction allows us to layer semantics of complex system, breaking them into
more manageable pieces.
API Package: Application Programming Interface: API contains a large number of packages
which offers a different way to look at and handles certain I/O operation.

AWT: Abstract Window Toolkit: It examines the standard controls and layout managers defined
by JAVA.
Bytecode: Bytecode is a highly optimized set of instructions designed to be executed by the java
run time system.
CSS: Cascading Style Sheets is a style sheet language used to describe the presentation
semantics (that is, the look and formatting) of a document written in a markup language. Its most
common application is to style web pages written in HTML and XHTML, but the language can
be applied to any kind of XMLdocument, including SVG and XUL.
Constraints : Any condition that limits the solutions to a problem.

Console: It refers to that portion of a computer which is used for communication between
operation or maintenance engineers and the computer mostly with the help of displays and
manual controls.
Encapsulation: Encapsulation is the mechanism that binds together code and data it
manipulates, and keeps both safe from outside interference and misuse.
Errors: An error is abnormal condition that arises in a code sequence at execution time.

Exception: An exception is abnormal condition that arises in a code sequence at error time.

Frontend: The part of project which is responsible for collecting input in various forms from the
user and to processing it to conform to a specification the backend can use.
Javax.swing : A java toolkit for developing graphical user interfaces (GUI) it includes elements
such as menus, toolbar, and dialogue boxes.
Java.io: It contains classes that are stream oriented and support input and output.Page | 145

Java.awt.event : Provides interfaces and classes for dealing with different types events fired by
awt components.

94

FTP|MINOR PROJECT

Java.sql : provides the API for accessing and processing data stored in a data source using the
java programming language.
Java.util : It contains the collection framework, legacy collection classes, event model, date and
time facilities, and internationalization utility classes.

JDK : Java Development Kit: It is a basically a software development kit which is use to write
and run java programs.

JDBC : Java Data Base Compiler: It provides a standard interface for accessing a relational. It
contains a set of classes and methods for issuing SQL statements, table updates, and calls to
stored procedures.
JRE : Java Runtime Environment: Is software which is required to run java applications
interpretively on a target hardware and operating system platform.
JVM : Java Virtual Machine: JVM is an interpreter for Bytecode. It provides the hardware
platform specifications to which you compile all java technology code.
URL : Uniform Resource locator: It is a unique address given to a particular web page.
J2SE : Java 2 Standard Edition (Core Java).

J2EE : Java 2 Enterprise Edition (Advanced Java).

NETBEANS :The software by Oracle community which is necessary to carry out all simulations and
synthesis.

PORT : In computer networking, a port is an endpoint of communication in an operating system. They


ranges from 0 to 65535(2^16 1).

95

FTP|MINOR PROJECT

You might also like