Вы находитесь на странице: 1из 21

LAN Chat Server

Made By : Alisha R Gonsalves (12070121503)


Dakshayaa Deepankar (12070121509)

Abstract

Our Java project is based on the LAN chat server. During this project we covered the
basics of using classes or features on:

Sockets : 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.

Threads : One way to create a thread in java is to implement the


Runnable Interface and then instantiate an object of the class. We need to override
the run() method into the class which is the only method that needs to be
implemented. The run() method contains the logic of the thread.

Swing : Swing is built on top of AWT and is entirely written in Java, using AWTs
lightweight component support. In particular, unlike AWT, the architecture of Swing
components makes it easy to customize both their appearance and behavior.
Components from AWT and Swing can be mixed, allowing us to add Swing support
to existing AWT-based programs. For example, swing components such as JSlider,
JButton and JCheckbox could be used in the same program with standard AWT
labels, textfields and scrollbars.

INTRODUCTION

Common mode of communication


CELLULAR PHONES
High service rates Not ECONOMICAL!!!.

SOLUTION ????

LAN CHAT SERVER!!!

FEATURES

Chatting
Voice Chat(can be implemented)
File Transfer(can be implemented)
Bulletin Board
Display of friend list

USE CASE DIAGRAM

CONTEXT DIAGRAM

DATA FLOW DIAGRAM

Networking (java.net)
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.
Network Socket
Allows a single computer to serve many client at once
As well as serving different information also
This is managed by port

Port

Numbered socket on a particular machine


Multiple client can connect on same port
Imaginary points
TCP/IP reserves the lower 1024 ports

Socket Basics
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
A socket is a connection between two hosts.
It can perform seven basic operations:
Connect to a remote machine
Send data
Receive data
Close a connection
Bind to a port
Listen for incoming data
Accept connections from remote machines on the bound port

Client vs. Server


Traditional definition
- Client: user of Network Services
- Server: Supplier of Network Services
Analogy: Company phone line
- Installing phone is like starting server
- Extension is like port
- Person who calls is the client : he specifies both
host(general company number) & port(extension)

WORKING

Programming Basics

Package: import java.net.*;


import java.io.*;

Opening a socket requires a hostname(or IP


Address) and Port Number
Socket client = new Socket( hostname ,port number);

The URL and URL Connection classes simplify


communication with web servers

Programming Basics(contd..)
Create an input Stream to read the response from server
BufferedReader in = new BufferedReader(new
InputStreamReader(client.getInputStream( ));
Create an Output Stream that can be used to send info to the
socket
PrintWriter out = new PrintWriter(client.getOutputStream( ));
out.println( Hi Dude!!);

out.print(Howz life!!);
Close the socket when done
client.close();

SERVER TO CLIENT COMMUNICATION CHANNEL

CLIENT TO SERVER COMMUNICATION CHANNEL

USES :
To efficiently communicate in a
1. Company
2. Institution
3. Hostel

LIMITATIONS
Delay of 2-3 seconds in voice transfer
Server fails whole system fails

Server

Client 1

Client 2

FUTURE EXPECTS
1. Integration of video chat using web cam.
2. Making it more secure.
3. Recovery management system.

THANK YOU!