How to customize and use the websocket sub-protocol? -

Source: Internet
Author: User
I learned from websocketAPI that websocket can customize sub-protocols. I want to know more about them, but it seems that there are no similar examples on the Internet. I learned from the websocket API that websocket can customize sub-protocols. I want to know more about them, but it seems that there are no similar examples on the Internet. Reply content: subprotocol is only a field in the header.

RFC 6455-The WebSocket Protocol
The WebSocket API Because the Websocket Protocol provides a packet-based reliable transmission protocol, it is not an application protocol as HTTP, its package does not have the Content-Type field to describe the Content like HTTP. It is a relatively underlying protocol, just like TCP, if you want to use it for communication, you usually need to set a protocol by yourself. Subprotocol can be used as a label for negotiation between the server and the client.

The client can declare its acceptable sub-protocol types during connection. This is the same as the Accept and Accept-Encoding header fields in the HTTP request header. It means that you can Accept or encode files of the type, usually compressed.

Accept: text/html, application/xhtml + xml, application/xml; q = 0.9, image/webp, */*; q = 0.8Accept-Encoding: gzip, deflate, sdch

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.