Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 22

GROUPCHATING

Contents:
1. Introduction

2. System Design

3. Software Specification

4. Forms

 Source code

 Out Put

5. Conclusion

6. Future Enhancement

7. Bibliography.

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 1
GROUPCHATING

INTRODUCTION

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 2
GROUPCHATING

INTRODUCTION
In this post, a group chat application using Multicast Socket (Java Platform SE 7) class
is discussed. A Multicast Socket is a (UDP) Datagram Socket, with additional
capabilities for joining “groups” of other multicast hosts on the internet.

users to enter amount to be converted (say currency in Dollars), and display the
converted amount (say currency in Euro).

Save the file as GroupChat.java and compile it using java c and then run the program
using two command line arguments as specified. A multicast host is specified by a class
D IP address and by a standard UDP port number. Class D IP addresses are in the
range 224.0.0.0 to 239.255.255.255, inclusive. The address 224.0.0.0 is reserved and
should not be used.

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 3
GROUPCHATING

SYSTEM DESIGN

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 4
GROUPCHATING

SYSTEM DESIGN

The term system is one that is universally used. A system is a purposeful set of
interrelated components that form an integrated whole and work together to achieve some
objective. Systems are usually hierarchical and so include other systems. These other systems are
called sub-systems. Some systems share common characteristics, including:

1. A system has structure, it contains parts or components that are directly or indirectly
related to each other.
2. A system has behavior, it contains processes that transform inputs into outputs.
3. A system has interconnectivity, the partsand processes are connected by structural and/or
behavioral relationships.
4. Structure and behavior of a system may be decomposed via sub-systems and sub-
processes to elementary parts and process steps.

The technical computer-based systems are systems that include hardware and software
components. Socio-technical systems include one or more technical systems but also include
knowledge of how the system should be used to achieve some broader objective. This means that
these systems have defined operational processes, include people who operate the system, are
governed by organizational policies and rules and may be affected by external constraints such as
national laws and regulatory policies.

Software engineering is critical for the successful development of complex, computer based
socio-technical systems. Software engineer should not simply be concerned with the software
itself but they should also have a broader awareness of how that software interacts with other
hardware and software systems and how it is supposed to be used by end users.

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 5
GROUPCHATING

The complexity of relationships between the components in a system means that the system is
more than simply the sum of its parts. It has properties that are properties of the system as a
whole. There are two types of emergent properties of system:

1. Functional properties. These properties appear when all the parts of a system work
together to achieve some objective. For example, when an alarm system turns on the siren
it is due to the co-operation between its components.
2. Non-functional properties. These properties are related to the behaviour of the system in
its operational environment. Examples of non-functional properties are reliability,
performance, safety and security for computer-based systems.

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 6
GROUPCHATING

SOFTWARE SPECIFICATION

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 7
GROUPCHATING

SOFTWARE SPECIFICATION

The software specification document enlist all necessary requirements that are required for the
project development. To device the requirement we need to have clear and through understanding
of the project team and customer.

1 Hardware Specification

System : I3 Processor.

Hard Disk : 500 GB.

Input Devices: Keyboard, Mouse

Ram : 4 GB

2 Software Specification

Operating system : Windows XP and Above

Coding Language : Java 1.7

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 8
GROUPCHATING

IDE : Eclipse

SOURCE CODE

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 9
GROUPCHATING

Source code:

import java.net.*;
import java.io.*;
import java.util.*;
public class GroupChat
{
private static final String TERMINATE = "Exit";
static String name;
static volatile boolean finished = false;
public static void main(String[] args)
{
if (args.length != 2)
System.out.println("Two arguments required: <multicast-host> <port-number>")
else
{
try
{
InetAddress group = InetAddress.getByName(args[0]);
int port = Integer.parseInt(args[1]);
Scanner sc = new Scanner(System.in);
System.out.print("Enter your name: ");
name = sc.nextLine();
MulticastSocket socket = new MulticastSocket(port);

// Since we are deploying


socket.setTimeToLive(0);
//this on localhost only (For a subnet set it as 1)

socket.joinGroup(group);
Thread t = new Thread(new
ReadThread(socket,group,port));

// Spawn a thread for reading messages


t.start();

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 10
GROUPCHATING

// sent to the current group


System.out.println("Start typing messages...\n");
while(true)
{
String message;
message = sc.nextLine();

if(message.equalsIgnoreCase(GroupChat.TERMINATE))
{
finished = true;
socket.leaveGroup(group);
socket.close();
break;
}
message = name + ": " + message;
byte[] buffer = message.getBytes();
DatagramPacket datagram = new
DatagramPacket(buffer,buffer.length,group,port);
socket.send(datagram);
}
}
catch(SocketException se)
{
System.out.println("Error creating socket");
se.printStackTrace();
}
catch(IOException ie)
{
System.out.println("Error reading/writing from/to socket");
ie.printStackTrace();
}
}
}
}
class ReadThread implements Runnable
{
private MulticastSocket socket;
private InetAddress group;
private int port;
private static final int MAX_LEN = 1000;
ReadThread(MulticastSocket socket,InetAddress group,int port)
{
this.socket = socket;
this.group = group;

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 11
GROUPCHATING
this.port = port;
}

@Override
public void run()
{
while(!GroupChat.finished)
{
byte[] buffer = new byte[ReadThread.MAX_LEN];
DatagramPacket datagram = new
DatagramPacket(buffer,buffer.length,group,port);
String message;

try
{
socket.receive(datagram);
message = new
String(buffer,0,datagram.getLength(),"UTF-8");
if(!message.startsWith(GroupChat.name))
System.out.println(message);
}
catch(IOException e)
{
System.out.println("Socket closed!");
}
}
}
}

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 12
GROUPCHATING

OUTPUT
KLS GOGTE INSTITUTE OF TECHNOLOGY
MCA PROGRAMME
BELAGAVI
Page 13
GROUPCHATING

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 14
GROUPCHATING

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 15
GROUPCHATING

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 16
GROUPCHATING

CONCLUSION

Grouping chating that the people are using, they will always find ways to
connecting the people in a grouping is a wise thing to check the different foreign exchange
options they have beforehand.

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 17
GROUPCHATING

FUTURE ENHANCEMENT

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 18
GROUPCHATING

FUTURE ENHANCEMENT

The project “CURRENCY CONVERTOR” . We can take only one output in current
situation. In future we can make to take more than one output in one attempt.

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 19
GROUPCHATING

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 20
GROUPCHATING

BIBLIOGRAPHY:

www.google.com

www.w3.school.com

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 21
GROUPCHATING

KLS GOGTE INSTITUTE OF TECHNOLOGY


MCA PROGRAMME
BELAGAVI
Page 22

You might also like