My Github address
Notes on data Structures and Algorithms
Notes for geek Time iOS Developer Class
IOS large factory interview high frequency algorithm summary
Summary of iOS interview materials
Socket
HTTP vs WebSocket
HTTP
Request characteristics: Communication can only be initiated by the client. Therefore, in order to realize the push technology, many websites used polling technology- Polling is sent by the browser to the server at regular intervals, such as every second
HTTP
Request, and the server returns the latest data to the client - In order to save server resources and bandwidth, and to communicate more in real time,
HTML5
It appears in the specificationWebSocket
agreement
- Polling is sent by the browser to the server at regular intervals, such as every second
WebSocket
andHTTP
Both are application – layer protocols- Actually,
TCP
It supports full-duplex communication (both clients and servers can send messages to each other). - just
HTTP
“Request-reply mode” limits TCP’s capabilities
- Actually,
- Websockets use ports 80(ws://), 443(WSS ://) and can bypass most firewall restrictions
- ws://example.com/wsapi
- wss://secure.example.com/wsapi
- with
HTTP
The difference is,WebSocket
You need to establish a connection first- This makes the
WebSocket
Become aStateful protocol
And part of the state information can be omitted in subsequent communication - while
HTTP
Requests may need to carry additional status information (such as authentication, etc.) with each request
- This makes the
WebSocket
WebSocket
Is an application layer protocol based on TCP that supports full-duplex communication- In 2011, it was standardized by IETF to RFC 6455 and later supplemented by RFC 7936
- Either client or server can send messages to each other
WebSocket
There are many application scenarios- Social subscriptions, stock fund quotes, sports updates, multimedia chat, multi-player games, etc
WebSocket – Establishes a connection
HTTPDNS
Cache
Response headers
Cache-Control
Decide whether to make a network requestLast-Modified
,ETag
The decision is to return304
or200