WebSocket detailed (a): Preliminary understanding of WebSocket technology

Source: Internet
Author: User

1. What is a socket? What is WebSocket?

What's the difference between the two people who have heard about WebSocket technology for the 1th time? WebSocket is the implementation of just porting the socket concept to the browser?

We know that two applications (processes) in the network need to communicate with each other at full duplex (that is, both sides can send messages to each other at the same time), the socket is needed, it can provide end-to-end communication, and for programmers, He just needs to create a socket instance at one end of an application (called a client) and provide the IP address and port it wants to connect to one end (called the server), while the other end (the server) creates another socket and binds the port to listen. Then the client connects to the server, the server accepts the connection, the two sides establish an end-to-end TCP connection, the connection can be two-way communication, and once the connection is established, there is no client service side of the communication between the two sides, providing the end-to-end communication. We can use this approach to build a desktop version of the IM program that allows users on different hosts to send messages. In essence, a socket is not a new protocol, it is simply a encapsulation of the TCP/IP protocol family communication mechanism in order to facilitate the programmer's network programming.

WebSocket is a part of the HTML5 specification, which draws on the idea of sockets, providing a full-duplex communication mechanism between the Web application client and the server side (note that the client service side). At the same time, it is a new application layer protocol, the WebSocket protocol is designed to provide a Web application and service-side full-duplex communication and a special application layer protocol, which is usually expressed as: Ws://echo.websocket.org/?encoding=text http/1.1, you can see that in addition to the previous protocol name and HTTP, its representation address is the traditional URL address.

As you can see, websocket is not simply porting the concept of sockets in a browser environment, and this article will go through a small demo to further explain the difference between the socket and the websocket in use.

WebSocket detailed (a): Preliminary understanding of WebSocket technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.