Home / Posts / Web Socket

Web Socket

Web socket are introduced in java EE7 JSR 356 is related to web socket and provides API for creating web socket applications. Web socket is an application protocol that for a ideas full-duplex communication between two peers over the TCP protocol. The web socket enables web applications to deliver a richer user experience.
In web socket application a web socket end point published by the server, and the client uses the End points URI to connect to the server. When the connection is Established Web socket protocol is symmetrical and the client & server can send messages to Each other when the connection is open, and they can close the connection at any time. Clients usually connect only to one server, and servers accept connections from multiple clients.
Web socket protocol has two parts
1) Hand shake
2) Data transfer
Client initiates the hand shake by sending a request to a web socket end point using its URI. It is comfortable with HTTP-based infrastructure. The web socket client API specified in JSR356 also enables you to access remote web socket end points from any JAVA applications.
Javax.websocket. Server.
Javax.Websocket.Endpoint
The java API for web socket enables you to create two kinds of end points
1. Programmatic end point
2. Annotated end point
Creation of programmatic end point:
End points are instance of endpoint class. This is in the part of web socket. To create a programmatic end point you extend the Endpoint class and override its life cycle methods.
To create an annotated end point: By using annotations creating annotation based end points are created.
After successfully create endpoint deploy these code into a specific URI in the application.
So that remote clients can connect to it.
Steps to create& deploy web socket end point.
1) Create end point class.
2) Implement life cycle methods of the end point.
3) Add business logic to end point.
4)Deploy the end point inside a web application.

About Santosh Kumar Gadagamma

I'm Santosh Gadagamma, an Experienced Software Engineer passionate about sharing knowledge in technologies like Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts, and all levels of software design, development, deployment, and maintenance. I believe computers are essential for the world's functioning, and I'm committed to helping others learn the skills they need to succeed in tech. My website is a valuable learning tool to help you reach greater heights in your education and career, and I believe that education has no end points.

Check Also

Google Keyword Planner

How to Use Google Key Word Planner

Google Keyword Planner is a free tool provided by Google Ads to help businesses and …