+ All Categories
Home > Technology > Client server chat application

Client server chat application

Date post: 23-Jan-2017
Category:
Upload: piyush-rawat
View: 436 times
Download: 9 times
Share this document with a friend
15
CLIENT-SERVER CHAT APPLICATION By Piyush Rawat PC Technology Pvt. Ltd.
Transcript
Page 1: Client server chat application

CLIENT-SERVER CHAT APPLICATION

By

Piyush RawatPC Technology Pvt. Ltd.

Page 2: Client server chat application

Networking Basics

• Transmission Control Protocol (TCP)• Port• Socket

Page 3: Client server chat application

TCP• This protocol ensures that the data sent over two points in a

Network is received in the same order as it is sent. This is ensured by receiving acknowledgements from the receiver side for every packet sent.

Page 4: Client server chat application

PORTS• It is an address which determines the data origin and delivery

points over the Network. It is not a hardware device, but a logical construct that identifies a service or process.

Page 5: Client server chat application

SOCKET• A socket is one endpoint of a two-way communication link

between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to.

Page 6: Client server chat application

Server Working• The server is based on multithreading concept, which runs a

separate thread for each client connected to it.• ServerSocket ss = new ServerSocket(3300); // a server socket is created try { while (true) { new Handler(ss.accept()).start(); } }

• The server is Broadcast type i.e. it allows the messages from one client to be sent to other client and vice-versa.

Page 7: Client server chat application

Client Working• The client requests connection to the server at a given port

and IP address.

• ip= getServerAddress(); //server address is received by user s = new Socket(ip, 3300); //new socket is created at particular IP

and port• Client is working on simple concept of creating new socket

and then sending and receiving messages • Request of clients are placed in a cue for server to resolve.

Page 8: Client server chat application

Classes and packages used• Server side:• javax.swingThis package is dealing in providing user interface, i.e. panels, scroll, text fields, etc.• java.ioThis package provides input/output facilities i.e. readers, writers, etc.• java.netThis package provides network related facilities like creating server sockets, accepting connections, etc.• java.utilThis package provides hashsets used for storing and updating objects of DataOutputStream and name of different client connected to server.

Page 9: Client server chat application

Continued..• Client side:• javax.swingHere also package is dealing in providing user interface, i.e. panels, scroll, text fields, buttons, etc.• java.ioThis package provides input/output facilities i.e. readers, writers, etc.• java.netThis package provides network related facilities like requesting server for connections, sending and receiving messages, etc.• java.utilThis package provides hashsets used for storing and updating objects of DataOutputStream and name of different client connected to server.

Page 10: Client server chat application

Final Implementation

Asking for IP address of server.

Page 11: Client server chat application

Asking for screen name

Page 12: Client server chat application

When user leaves

Page 13: Client server chat application

Scope• Can be used for private chat over LAN and over Internet*.• Can be further developed for file transfer.• Can be used for broadcasting notices in an organization.• Secure and reliable.• Can also be used as a backup if there is sudden breakdown of

internet connection.• Simple and effective with low memory and resource usage.• No dedicated server is required if the application is used for

Local Area Network(LAN) i.e. any PC can become server.• Basically this application can be for communication purpose

anywhere.*For over the internet connection a dedicated server with global IP will be required.

Page 14: Client server chat application

QUESTIONS ?

Page 15: Client server chat application

Thank you


Recommended