Professional Documents
Culture Documents
(QUICK MESSENGER)
Submitted By:1.
S.Rithika
07981A05C1 07981A05C1
2. P.Lavanya
ABSTRACT
Quick messenger is a utility which allows a group of users to communicate among each other through electronic text messaging. The chat system includes a chat server and plurality of chat clients in a network. The main goal of the project is to reduce the burden on the Chat server. The basic idea is that the chat server only negotiates the clients for communication without involving itself in the data transfer. This application doesnt require internet connection for communication. A group of computers in a Local Area Network (LAN) are enough for utility. When a user makes a request to chat server, the name and IP address of the user is kept in the server and the user get the lists of online users and their corresponding IP addresses. The user selects a name/IP address from the list to communicate straightly without the participation of server. The advantage is, even the server is stopped, and the communication among the negotiated clients is not affected.
EVALUATION SHEET
1. 2. 3.
Title of Project: QUICK MESSANGER Year of Submission: 2011 Name of The degree: B.Tech
6. Result Approved/Rejected
Contents
1. Introduction-------------------------------------------5
Feasibility Analysis-----------------------------------6 2.1 Economic Feasibility----------------------------6 2.2 Technical Feasibility----------------------------7 2.3 Operational Feasibility-------------------------7
3 Requirement Analysis---------------------------------8 3.1 Existing system-----------------------------------8 4 Requirement specifications---------------------------9 4.1 Functional requirement-----------------------9 4.2 Non-functional requirement-----------------11 4.3 Goal of implementation-----------------------11 5 .System requirement specification----------------12 5.1 Hardware specification-----------------------12 5.2 Software specification-------------------------13 5.3 Software description (java features) ------13 6. Software Design---------------------------------------18 6.1 Generalised design approach----------------19 6.2 Use case model-----------------------------------19 6.3 Domain model------------------------------------22 6.4 Sequence diagram-------------------------------23 6.5 Class diagram------------------------------------27 7. Coding---------------------------------------------------28 8. Testing---------------------------------------------------65 8.1 Testing objectives--------------------------------65 8.2 Testing principles---------------------------------66 8.3 Testing strategies---------------------------------66 8.4 Types of testing------------------------------------66 9. Future development-----------------------------------70 `10. Conclusions---------------------------------------------71 11. Bibliography-------------------------------------------72
1. Introduction
Establishing relation and maintaining communication is a vital part of everybodys life. There are so many ways and media through which people can communicate with each other. Some of the basic means of communication are voice, audio, video, picture, text etc. The most widely used system among them is electronic messaging due to its inexpensiveness.
Quick messenger project is an afford to make the communication process cheaper and efficient among people. To make the process less expensiveness, we need to use the devices of low configuration, open sources and etc. To make the process more efficient, the message transfer delay must be reduced and some other factors like network bandwidth etc. must be taken care.
In order to achieve the above goals, the quick messenger utility is developed using java (an open source).It involves both connection-less (UDP) and Connection-oriented services (TCP) of network. It is designed in such a manner that even a Pentium-pro machine can serve as a server as well as a client. It closes the connections automatically whenever they are not required.
2.Feasibility Analysis:
5
The aim of feasibility study is to determine whether developing the product is financially and technically feasible. The feasibility study involves analysis of the problem and collection of data which would be input to the system, the processing required to be carried out on these data, the output data required to be produced by the system as well as study of various constraints on the behaviour of the system. The collected data are analyzed to arrive at the following:
An abstract definition of the problem. Formulation of the different solution strategies. Examination of alternatives solution strategies and their benefits, indicating resources required, development, cost and time in respect of each of the alternative solutions.
2.1.Economic Feasibility
This is based on questions like will the system provide benefits greater than the costs? .The feasibility study presents intangible as well as tangible benefits in a formal way. A relatively detailed analysis of the costs of both development and operations of various alternatives is also presented. The project Quick Messenger is economically feasible in the following manner:
The preliminary investigation is done with an affordable cost. The charges of hardware and software implemented in this project are less costly. This project hopes no costly errors arise in near future.
This project uses java which is a open source.
This is based on questions like can the proposed application be implemented with existing equipment, software technology and available personnel. If the new technology is required, what is the likelihood that it can be developed? Analysis of project risk relative to technical feasibility includes not only whether the technology available on the market but also its state of the art both in absolute terms and relative to companys current technical specification. The project Quick Messenger is technically feasible in the following manner: The proposed system can run well in the existing system The proposed system provides adequate responses to enquires regardless of the number or location of users. The proposed system can be expanded if desired. The proposed system provides guarantee in terms of accuracy, reliability, easy access and data security.
Computers need to be connected to each other as there is a client-server system being
This is based on questions like will the system be used if it is developed and implemented? Will these be resistance from users that will undermine the possibility application benefits? This analysis may invoke a subjective assessment of political and managerial environment in which the system will be implemented. In general the greater the requirements for change in the user environment in which the system will be installed the greater the risk of implementation failure. The project Quick Messenger is operationally feasible in the following manner: The proposed system would definitely be used if developed and implemented. The proposed system has the facility to incorporate any kind of change put on it.
3. Requirement ANALYSIS
7
System analysis is an activity that encompasses most of the tasks that are called computer system engineering. Analysis is a detailed study of various operations performed by a system. Once analysis is completed, the analyst has firm understanding of what is done. In other words, its a reduction of an entire by studying the various operations and their relationship within the system; an examination of business activity, with the overview of identifying the problem areas and recommending alternate solutions. The objectives of the system analysis are Identifying the needs Analyzing the existing and proposed system Evaluating the feasibility study Perform economical and technical analysis Identifying the hardware and software requirements Allocating functions to hardware and software Create a system definitions
The following problems are encountered while using the existing system.
Problems:
Requires a high configuration machine to act as a server Single point of failure(if server fails, the entire system fails) Bandwidth consumption is high Requires internet connection.
So we need to design a system for quick messaging which will eradicate the above problems.
4. Requirement Specification.
Purpose: The purpose is to describe the external requirements for an on lone chatting system. Overall Description:
This application is specifically designed for the college, JITM. The college has nearly 10,000 computers which are LAN connected. The IP addresses to all the systems are given by a DHCP server. All the systems are behind a NAT router. They access internet through a proxy server. This utility is to facilitate online instant messaging. Through a single computer, a person can establish communication as many as computers he requires. When a user terminates, it must be notified to all who are connected to him.
Output: a chat window appears for messaging. R3: Continue Chatting Description: This function is to provide the user with message sending and accepting capability. This sends a message to the destination as well as receives the message from other online users to a given system/node.
R3.1.send/receive message State: The user has logged in, invited a online user for chatting and the window for chatting has been displayed Input: message to be sent. Output: the sent message along with received messages are displayed R3.2.Terminate session State: The user has logged in, invited a online user for chatting and the window for chatting has been displayed Input: close option. Output: Connection to remote user is terminated and the chatting window disappears. R4: Logout Description: This function is used to logout. A message is sent to the server to remove the corresponding entry from the online user list. R4:1: select close option Input: close option Output: The main window displaying online user list is disappeared.
It should take advantages of both TCP and UDP protocols. The burden on the server should be less. So a low-configuration machine can be used as server for cost-effectiveness. Should take less time to transfer the messages. Even, the server fails, the link between established clients should not be affected
10
Should Work on both intranet and internet. It should support very large number of users.
Requirements generally specify: The operating system must be user-friendly and support multitasking with ease. Processing speed of the system shouldnt deteriorate during execution. Security and protection should also be taken into consideration as any number of computers may be used for communication later on. The operating systems must be portable enough to meet the requirements of the user. Such an operating system must be opted which runs on more CPUs and platforms than any other computer operating system
Hardware and software Requirements: The minimum hardware and software needed on the client machine are as follows:
12
only reliable, portable and distributed but also simple, compact and interactive. Sun Microsystems officially describes Java with the following attributes: Compiled and Interpreted Platform-Independent and Portable Object-Oriented Robust and Secure Distributed Familiar, Simple and Small Multi threaded and Interactive High Performance Dynamic and Extensible Although the above appears to be a list of buzzwords, they aptly describe the full potential of the language. These features have made java will also become the premier language for general purpose stand-alone applications.
13
Java ensures portability in two ways. First, java compiler generates byte code instructions that can be implemented on any machine. Secondly, the size of the primitive data types is machineindependent.
5.3.3 Object-Oriented
Java is a true object-oriented language. Almost everything in java is an object all programs code and data reside within objects classes. Java comes with an extensive set of classes, arranged in packages that we can in our programs by inheritance. The object model in Java is simple and easy to extend.
5.3.5 Distributed
Java is designed as a distributed language for creating applications on networks. It has the ability to share data and programs. Java applications can open and access remote objects on Internet as easily as they can do in a local system. This enables multiple programmers at multiple remote to collaborate and work together on a single project.
14
C and C++ and therefore, Java code looks like a C++ code. In fact, Java is a simplified version of C++.
Because the Java programming language is platform-independent, the AWT must also be platform-independent. The AWT was designed to provide a common set of tools for graphical
15
user interface design that work on a variety of platforms. The user interface elements provided by the AWT are implemented using each platform's native GUI toolkit, thereby preserving the look and feel of each platform. This is one of the AWT's strongest points. The disadvantage of such an approach is the fact that a graphical user interface designed on one platform may look different when displayed on another platform. A graphical user interface is built of graphical elements called components. Typical components include such items as buttons, scrollbars, and text fields. Components allow the user to interact with the program and provide the user with visual feedback about the state of the program. In the AWT, all user interface components are instances of class Component or one of its subtypes. Components do not stand alone, but rather are found within containers. Containers contain and control the layout of components. Containers are themselves components, and can thus be placed inside other containers. In the AWT, all containers are instances of class Container or one of its subtypes
1. Sockets: All references to sockets in this article are references to TCP/IP. A socket is a generalized interprocess communication channel. A socket is also a virtual communication conduct between two processes, these processes may be local (residing on the same computer) or remote. A socket is the combination of an IP address and a port number. Formally a socket is defined by a group of four numbers, these are the remote host identification number or address the remote host port number The local host identification number or address The local host port number. 2. TCP /IP: TCP (Transmission Control Protocol) is sometimes also referred to as stream. TCP/IP includes many protocols and many ways to communicate. The most common transports are TCP and UDP. TCP is a connection-based protocol - that is, you must connect to a server before you can send data - that guarantees delivery and accuracy of the data sent and received on the connection. TCP also guarantees that data will arrive in the order that it's sent. Most things that use TCP/IP use TCP for their transport. 3. Client: A client is a process that initiates a connection. Typically, clients talk to one server at a time. If a process needs to talk to multiple servers, it creates multiple clients. 4. Server: A server is a process that answers incoming requests. A typical server handles numerous requests from many clients simultaneously. Each connection from the server to the client1. 5. IP Address:
16
Each computer on a TCP/IP network has a unique address associated with it. Some computers may have more than one address associated with them. An IP address is a 32-bit number and is usually represented in dot notation, e.g. 192.168.0.1. Each section represents one byte of the 32-bit address. 6. Ports: A port is an integer number that identifies which application or service the client wishes to contact. When an application (a server) is ready to accept incoming requests, it begins to listen on a port. This is why sometimes application or protocol is used interchangeably with the word port. When a client wants to talk to a server, it must know where the application is (the IP address/phone number), and which port (extension) it's listening (answering) on. Typically, applications have a fixed port so that no matter where they run, the port is fixed for that type of application.
6. Software Design
Software design deals with transferring the customer requirements ,as described in the SRS document ,into a form that is implementable using a programming language. For design to be
17
easily implementable in a convenient programming language, the following items must be designed during design phase. Different modules required to implement the design solution Control relationship among the identified modules Interface among different modules .the interface among different modules identifies the exact data items exchanged among the modules. Data structure of individual modules Algorithm required to implement the individual modules
Thus, the objective of design phase is to take SRS document as the input and produce above mentioned documents before completion of the design phase. We can broadly classify the design activities into two important parts. Highlevel design Detailed design
The first three activities as mentioned above comes under high level design and the remaining two activities comes under the detailed design. Design Approaches. There are fundamentally two different approaches to software design Function-oriented design Object-Oriented Design
Object-oriented Design(OOD)
OOD advocates a radically different approach compared to the function-oriented design approach. In traditional design approaches all the functions that the system needs to support should first be identified and then implemented. In contrast, the OOD paradigms suggest that the natural objects occurring in a problem should first be identified and then implemented. In OOD ,state information is not represented in a centralized shared memory but is distributed among objects of the system. Function-oriented techniques, such as SA/SD, group the functions together if, as a group, they constitute a higher level function. On the other hand, the OOD techniques group the functions together on the basis of the data they operate on.
18
19
Text description
U1: Login: using this case, the user connects to the chat server and registers himself by providing necessary details. In turn, the user gets the name of all users. Scenario 1: Main line sequence User: enter server address. System: display prompt to enter name. User: enter the name. System: display the set of online users. Scenario 2: At step (4) of the main line sequence.
20
Scenario 3: At step (4) of the main line sequence 4: system: display message: user already exists.
U2: Invite Chat: using this use case, the user invites a online user for chatting.
User: Refreshes the online user list and selects one online-user among them. System: displays a chat-window for chatting.
U3: Chat: this use code is to send and receive message to and from an online user Respectively.
Scenario1: main line sequence: User: types the messages and selects option. System: sends the message to the destination.
Scenario2: at step-1 of main line sequence: User: selects the close option. System: closes the chat window and sends terminate message to destination.
21
The Boundary objects are those with which the actor interacts.The boundary objects are mainly responsible for user interaction.Therefore,they normally donot include any processing logic. Entity objects normally holds information such as data tables and files that need to outlive use case execution. The controller object coordinate the activities of a set of entity objects and interface with the boundary objects to provide the overall behaviour of the system.
MainAgentG UI
CloneAgentG UI
LoginGUI
MainServer
MainAgent
CloneAgent
Message
A sequence diagram shows interaction among objects as a two-dimensional chart.the chart is read from top to bottom.The objects participating in the interaction are shown at the top of the chart as a boxes attached to a vertical dashed line.The vertical dashed line is called the objects life line.The rectangle drawn on the life line is called activation symbol and indicates that the object is active as long as the rectangle exists.Each message is indicated as an arrow between the life lines of two objects.
: LoginGUI
Login
: MainAgent
Login Info
:Main Server
: Hash Table
Connect [errconnection] Show error Show error CheckDuplicate Matc h* [Duplicate] Show error Show error Ins ert Online user set Display user set Disconnect
23
: MainAgentGUI
Refresh/Logout
: Hash Table
[Refresh]
Refre sh
User List User List Display user set [Logout] Delete user Disconnect
24
: MainAgent
: Remote MainAgent
Create
:
CLoneAgentGUI
25
: Clone Agent
:
CLoneAgentGUI
Message*
DisplayMessage
* Sent
sent message*
Message*
Displaymessage*
close
26
Clone Agent Datagram Socket Datagram Packet 1 Datagram Packet 2 Receive () Send Data ()
Message Name * Action Text GetName () SetName () GetAction () Set Action () GetMessage () SetMessage () 27
7. CODING
Input and Output System Design Screen Slots of Project
First When We will execute the Program by typing java LoginGUI, Figure-1 appears
28
In the text box, the user need to type the server-ip address.( figure-2).Or else one can enter the name of the computer in which the server is running.(as figure-3). The code corresponding to above GUI is as follows.
//file name: LoginGUI.java import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; import java.applet.*;
public class LoginGUI extends Frame implements ActionListener { TextField serverIP; Button ok; DialogMsg d1; DialogInput d2; public LoginGUI() { super("user login for chatting"); setSize(200,150); setResizable(false); setBackground(Color.lightGray);
29
d1=new DialogMsg(this); d2=new DialogInput(this); add(new Label("Server IP:")); add(serverIP); add(new Label(" add(ok); ok.addActionListener(this); MyWindowHandler handle=new MyWindowHandler(this); addWindowListener(handle); setVisible(true); "));//to add a blank line
} public void actionPerformed(ActionEvent ae) { int sport=0,cport=0; if(ae.getSource()==ok) { setVisible(false); d2.setMsg("enter a name by which u want to chat"); MainAgentGUI jkl=new MainAgentGUI(serverIP.getText(),d2.getText()); }
30
} public static void main(String args[]) { new LoginGUI(); } } After entering the serverIP, Figure-1 appears. The user need to enter a name by which he will be known to all other online users. If the name field is left blank,figure-3 appears as a message.
31
//File name:DialogInput.java import java.awt.*; import java.awt.event.*; public class DialogInput extends Dialog implements ActionListener { Label msg; TextField text; Button ok; String str; DialogMsg d1; Frame frm; public DialogInput(Frame s) { super(s,"Message",true); //setBackground(Color.blue); //setForeground(Color.white); setFont(new Font("Symbol",Font.BOLD,15)); frm=s; msg=new Label(""); ok=new Button(" ok "); //ok.setBackground(Color.blue); //ok.setForeground(Color.white); text=new TextField(20); //text.setBackground(new Color(0x0000bb));
32
} public String getText() { return(str); } public void setMsg(String s) { msg.setText(" "+s); setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==ok)
33
{ if(text.getText().equals("")) d1.setText("you must need to enter a valid name else{ setVisible(false); str=text.getText(); } } } ");
//File name:DialogMsg.java import java.awt.*; import java.awt.event.*; public class DialogMsg extends Dialog implements ActionListener { Label msg; Button ok; public DialogMsg(Frame s) { super(s,"Message",true); setFont(new Font("Symbol",Font.BOLD,15)); //setBackground(Color.blue);
34
//setForeground(Color.white); msg=new Label(""); ok=new Button(" ok "); //ok.setBackground(Color.blue); //ok.setForeground(Color.white); setLayout(new FlowLayout()); setSize(350,100); add(msg); add(ok); ok.addActionListener(this); } public void setText(String str) { msg.setText(" "+str+" setVisible(true); } ");
35
After typing the name, the figure -1 appears. It contains the list of current users. Select a online user to chat (as shown in figure-2).The coding for above output is as shown below.
//file name:MainAgentGUI. import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.net.*; public class MainAgentGUI extends Frame implements ActionListener { java.awt.List users;
36
TextField name; Button find,refresh; Panel p; MyWindowHandler handle; MainAgent magent; public MainAgentGUI(String IP,String name1) { setSize(280,380); setTitle(name1); setResizable(false); setFont(new Font("Symbol",Font.BOLD,20)); setBackground(new Color(0xcccccc)); //setForeground(Color.yellow); setLayout(new FlowLayout()); add(new Label("List of online users")); users=new java.awt.List(10,false); p=new Panel(); name=new TextField(20); name.setBackground(new Color(0xeeeeee)); users.setBackground(new Color(0xeeeeee)); //users.setForeground(Color.cyan); users.setFont(new Font("Symbol",Font.BOLD,15)); setFont(new Font("Symbol",Font.BOLD,15)); find=new Button(" Find ");
37
find.setBackground(new Color(0xdddddd)); refresh=new Button(" Refresh List "); refresh.setBackground(new Color(0xdddddd)); add(users); //add(new Label(" p.add(name); p.add(find); "));
38
public void addUsers(Hashtable hstable) { users.removeAll(); Enumeration enm=hstable.keys(); while(enm.hasMoreElements()) users.add((String)enm.nextElement()); } public void dispose() {
public void actionPerformed(ActionEvent ae) { if(ae.getSource()==users) { String str=users.getSelectedItem(); System.out.println("double clicked "+str); magent.createCloneAgent(str); } if(ae.getSource()==find)
39
addUsers(magent.hstable); }
} /* public static void main(String[] args) { new UserList(); System.out.println("Hello World!"); }*/
40
After inviting a online user for chatting,the above windows are displayed to the users(involved chatting). The code is as follows. import java.awt.*; import java.awt.event.*;
41
import java.net.*; import java.io.*; public class CloneAgentGUI extends Frame implements ActionListener { TextArea allMessage; TextArea sentMessage; Button send; Thread threadR; CloneAgent cgnt; public CloneAgentGUI(String address,String name)throws Exception { MyWindowHandler handle=new MyWindowHandler(this);
Keyhandler khandle=new Keyhandler(); addKeyListener(khandle); setSize(280,400); setBackground(Color.gray); setForeground(Color.blue); setResizable(false); setLayout(new FlowLayout()); allMessage=new TextArea("",10,30,TextArea.SCROLLBARS_VERTICAL_ONLY); allMessage.setEditable(false); allMessage.setBackground(new Color(0xdddddd)); //allMessage.append("");
42
setFont(new Font("Symbol",Font.BOLD,12)); add(new Label("********Chat Utility*******")); add(allMessage); add(new Label(" ")); add(sentMessage); add(send); setVisible(true); send.addActionListener(this); sentMessage.addKeyListener(khandle); addWindowListener(handle); setVisible(true); cgnt=new CloneAgent(address,name);
43
// System.out.println("uma is great"); try{ cgnt.sendData("","stop"); } catch(Exception e) { e.printStackTrace(); } super.dispose(); } / ************************************************************************* ******************************/ public void actionPerformed(ActionEvent ae) { try{ if(ae.getSource()==send) { allMessage.append("\nme: "+sentMessage.getText()); cgnt.sendData(sentMessage.getText(),"continue"); sentMessage.setText(""); } } catch(Exception e) {
44
e.printStackTrace(); } } /* public static void main(String[] args) { new ClientInterface(); System.out.println("Hello World!"); }*/ / ************************************************************************* ***************/
public void run() { while(true) { try{ byte data[]=new byte[500]; DatagramPacket receive=new DatagramPacket(data,data.length); cgnt.socket.receive(receive); String str=new String(receive.getData()); Message m=Message.fromString(str);
45
}//Receive / ************************************************************************* ****************************/ class Keyhandler extends KeyAdapter { public void keyTyped(KeyEvent ke) { try{ if(ke.getKeyChar()=='\n') { allMessage.append("\nme: "+sentMessage.getText());
46
//File name:Message.java
47
{ private String uname; private String action; private String message; public Message(String name,String act) { uname=name; action=act; } String getName() { return(uname); } String getAction() { return(action); } String getMessage() { return(message); } void setMessage(String s) { message=new String(s);
48
public String toString() { return(uname+"#~$%"+action+"#~$%"+message); } public static Message fromString(String s) { int i; i=s.indexOf("#~$%"); Message k=new Message("",""); k.setName(s.substring(0,i)); s=s.substring(i+4); i=s.indexOf("#~$%"); k.setAction(s.substring(0,i)); s=s.substring(i+4);
49
k.setMessage(s); return(k);
} //file CloneAgent.java import java.net.*; import java.io.*; public class CloneAgent { Message msg; DatagramSocket socket; DatagramPacket sendpacket;
msg=new Message(name,""); int i=address.indexOf(":"); String IP=address.substring(0,i); String port=address.substring(i+1); Message m=new Message(name,"CONNECT");
50
sendData("","START");
public void sendData(String str,String act)throws Exception { msg.setAction(act); msg.setMessage(str); byte data[]=msg.toString().getBytes(); sendpacket.setData(data); socket.send(sendpacket);
} } //file CloneAgent.java
51
import java.util.*; import java.net.*; public class MainAgent { public Hashtable hstable;//to store all online users DatagramSocket dsocket; String serverIP,uname; int cport=8888; Frame stp;
52
public void createCloneAgent(String str) { try { //new ClientInterface((String)hstable.get(str),cfg.getname()); Runtime r=Runtime.getRuntime(); Process p=r.exec("java CloneAgentGUI "+(String)hstable.get(str) +" "+uname); new Dthread(p).start(); } catch(Exception e){e.printStackTrace();}
}
53
public boolean connectToMainServer(String action) { Socket con; ObjectInputStream input; ObjectOutputStream output; Message msg;
try{ con=new Socket(serverIP,9999); output=new ObjectOutputStream(con.getOutputStream()); output.flush(); input=new ObjectInputStream(con.getInputStream()); msg=new Message(uname,action); msg.setMessage(""+cport);
output.writeObject(msg); output.flush(); Object obj=input.readObject(); if(obj instanceof Message) { System.out.println("of type Message"); DialogMsg d=new DialogMsg(stp); d.setText(" already exists.try another name");
54
System.exit(0); return(false); } if(obj instanceof Hashtable) { System.out.println("of type hashtable"); hstable=(Hashtable)obj; return(true); } } catch(UnknownHostException e) { DialogMsg d1=new DialogMsg(stp); //setVisible(false); d1.setText(" System.exit(0); invalid serverIP ");
} catch(SocketException e) { DialogMsg d1=new DialogMsg(stp); //setVisible(false); d1.setText(" System.exit(0); invalid server PORT ");
55
} catch(Exception e) { e.printStackTrace(); DialogMsg d1=new DialogMsg(stp); //setVisible(false); d1.setText(" an exception occured "); System.exit(0); } return(false); }
//file Dthread.java import java.io.*; class Dthread extends Thread { Process prp; Dthread(Process p) { prp=p;
56
} public void run() { try{ InputStreamReader ir=new InputStreamReader(prp.getInputStream()); BufferedReader br=new BufferedReader(ir); System.out.println(br.readLine()); prp.destroy(); } catch(Exception e) { e.printStackTrace(); } }
} //MyWindowHandler.java
import java.awt.*; import java.awt.event.*; public class MyWindowHandler extends WindowAdapter { private Window s;
57
s.dispose(); } }
//SERVER program. //MainServer.java import java.net.*; import java.io.*; import java.util.*; public class MainServer { ServerSocket srvsocket; Hashtable users; boolean status; MainServer() { try{
58
new ClientHandle(s,users).start(); } }
59
catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { System.out.println(">>CHAT SERVER STARTED.................."); new MainServer().runServer(); System.out.println("Hello World!"); } }
public class ClientHandle extends Thread { Socket client; ObjectInputStream input; ObjectOutputStream output; String IPadd;
60
Message msg; public static Hashtable users; //public static Daemon; public ClientHandle(Socket s,Hashtable k) { users=k; try{ client=s; input=new ObjectInputStream(client.getInputStream()); output=new ObjectOutputStream(client.getOutputStream()); IPadd=client.getInetAddress().getHostAddress(); System.setOut(new PrintStream(new FileOutputStream("c:\\chatServer.log",true))); System.out.print(IPadd+" Date dt=new Date(); System.out.print(dt.toString()+" "); ");
try{
msg=(Message)input.readObject(); if(msg.getAction().equals("INSERT")) insert(); else if(msg.getAction().equals("REFRESH")) refresh(); else if(msg.getAction().equals("DELETE")) delete(); client.close(); } catch(Exception e) { e.printStackTrace(); } } synchronized { String name=msg.getName(); if(users.containsKey(name)) output.writeObject(msg); else { users.put(name,IPadd+":"+msg.getMessage()); private void insert() throws Exception
62
System.out.println(IPadd+":"+msg.getMessage()); System.out.println(name+":logged In"); output.writeObject(users); } output.flush(); } private void refresh() throws Exception { output.writeObject(users); System.out.println(msg.getName()+":Refreshed"); output.flush(); } private void delete()throws Exception { users.remove(msg.getName()); output.writeObject(users); System.out.println(msg.getName()+":logged Out"); output.flush(); }
63
When the User enters wrong serverIp, the above sequence of operations takes place.
64
8. TESTING
8.1 TESTING OBJECTIVES:
1. Testing is a process of executing a program with the intent of finding an error. 2. A good test case is one that has a probability of finding an as yet undiscovered error. 3. Testing is a critical element of quality assurance. 4. Represents the ultimate review of specification, design and coding. 5. Testing presents an interesting anomaly for the software engineer.
Verification refers to the set of activities that ensure that the software correctly implements a specific function.
65
Validation refers the sets of activities that ensure that the software has been built is traceable to customers requirements.
Thus a software product goes through following levels of testing: 8.4.1 > Unit testing 8.4.2> Integration testing 8.4.3> System testing
66
every input data belonging to the same equivalence class. The main idea behind defining the equivalence class is that testing the code with any one value belonging to an equivalence class is as good as testing the software with any other value belonging to that equivalence class. Equivalence classes for software can be designed by examining both input and the output data.
67
plan. The integration plan specifies the steps and the order in which are combined to realize the full system. After each integrated step, the partially integrated system is tested. Anyone (or a mixture) of the following approches can be used to devlop the test plan.
Big -bang approach.
It is the simplest integration testing approach, where all the modules making up a system are integrated in a single step. Top-down approach. Top-down integration testing starts with the main routine and one or two subordinate routines in the system. After the top-level skeleton has been tested, the immediate subroutines of the skeleton are combined with it and tested. Bottom up approach. In bottom-up testing, each subsystem is tested separately and then the full system is tested. A subsystem might consist of many modules which communicate among each other through welldefined interfaces. Mixed approach. A mixed (also called sandwiched) integration testing follows a combination of top-down and bottom-up testing approaches. Systems tests are designed to validate a fully developed system to assure that it meets its requirements. There are essentially three main kind of system testing: Alpha testing. Alpha testing refers to the system testing carried out by the test team within the developing organization. Beta testing. Beta testing is the system testing performed by a select group of friendly customers. Acceptance testing. Acceptance testing is the system testing performed by the customer to determine whether to accept or reject the delivery of the system.
8.4.3 Performance testing Performance testing is carried out to check whether the system meets the non-functional requirements identified in the SRS document. There are several types of performance testing as discussed below. The type of performance testing to be carried out on a system depends on the different non-functional requirements of the system documented in the SRS document. All performance tests can be considered as black- box tests.
68
Stress testing: Stress testing evaluates system performance when it is stressed for short periods of time. Stress tests are black-box tests which are designed to impose a range of abnormal and even illegal input conditions so as to stress the capabilities of the software. Volume testing: It is especially important to check whether the data structures (arrays, queues, stacks, etc.) have been designed successfully for extra ordinary situations. For example, a compiler might be tested to check whether the symbol table overflows when a very large program is compiled. Configuration testing: Configuration tasting is used to analyze system behavior in various hardware and software configurations specified in the requirements. Sometimes systems are built in variable configurations for different users Usability testing: This testing pertains to check the user interface to see if it meets all the user requirements. During usability testing, the display screens, messages, report formats, and other aspects relating to the user interface requirements are tested.
69
8. FUTURE DEVELOPMENT
The above documented application can be further enhanced in future in many ways. Implementing File transfer application. Voice communication facility Detecting online-clients automatically Establishing connection to server automatically.
70
10. CONCLUSION
Thus the project entitled quick messenger has been successfully designed and implemented. The project is designed, tested and finally implemented in a systematic manner. It is also found that the project suits the needs of the company in all aspects. In already existing system the system failed to perform the various task. And the performance of the system was very poor. Which is been rectified over here. At every phase of the project development, the feasibility study was done using the system flow diagram. Also data control flow validation was done to ensure the reliability of software and to conform the need and utility of software. This software can be extended and enlarged with a little effort to make it possible to world for all other departments.
71
11. Bibliography
Deitel & Deitel, How to Program Java, Third Edition, Pearson Education(2000) R.K Selva Kumar Java Programming , Fourth Edition, N.V Publication. David Reilly & Michael Reilly Distributed Computing and Java Networks Addison-Wesley Professional. http://pandonia.canberra.edu.au/ClientServer/socket/socket.html Search for Socket Programming in www.google.com Search in wikipedia.org Fundamentals Of Software Engineering,2nd Edition , Rajib Mall, PHI
72