client server chat application
TRANSCRIPT
![Page 1: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/1.jpg)
CLIENT-SERVER CHAT APPLICATION
By
Piyush RawatPC Technology Pvt. Ltd.
![Page 2: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/2.jpg)
Networking Basics
• Transmission Control Protocol (TCP)• Port• Socket
![Page 3: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/9.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/10.jpg)
Final Implementation
Asking for IP address of server.
![Page 11: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/11.jpg)
Asking for screen name
![Page 12: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/12.jpg)
When user leaves
![Page 13: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/14.jpg)
QUESTIONS ?
![Page 15: Client server chat application](https://reader034.vdocuments.mx/reader034/viewer/2022042502/5885817b1a28abbb7e8b7555/html5/thumbnails/15.jpg)
Thank you