Php + websocket Simple Chat Room practice, websocket Construction
1. Preface
There is a simple chat room in the company's game. After learning about it, I learned that it was implemented by node + websocket. I think php will also be used as a simple chat room. As a result, I collected various materials to read documents and find instances. I also wrote a simple c
With the help of node practices WebSocket, node practices WebSocket
I. WebSocketOverview
WebSocket protocol,It is based on TCP rather than HTTP.
As follows:
Ws: // 127.0.0.1 or wss: // 127.0.0.1 is a WebSocket request.
Note:WsWebSocketProtocol, wssIndicates encrypted WebSocketProtocol.
WebSocketThe advan
time, typically the length of the interval is affected by the update frequency of the service side and the time the client processes the updated data. The disadvantage of this way is obvious, is that the browser to constantly send requests to the server to obtain the latest information, causing the server pressure is too large, occupy broadband resources. Using streaming AJAXStreaming Ajax is a long-connection maintenance mechanism implemented via
.
The server stores this ticket (i.e. a database or cache), and also returns it to the client.
The client opens the WebSocket connection, and sends along this "ticket" as part of a initial handshake.
The server can then compare this ticket, check for source IPs, verify that the ticket hasn ' t been re-used and hasn ' t expired, And do any other sort of permission checking. If all goes well, the WebSock
automatically issued a request, the server's message pulled back actively, in this case, we need to constantly send requests to the server, however the HTTP The header of the request is very long, and the data contained in it may be just a small value, which can consume a lot of bandwidth and server resources.
And the most new technology to do polling effect is comet– using AJAX. However, although this technique can achieve full-duplex communication,
BackgroundPreviously, many websites used polling to implement push technology. Polling is at a specific time interval (for example, 1 seconds), the browser sends an HTTP request to the server, and the server returns the latest data to the browser. The disadvantage of polling is obvious, the browser needs to constantly make requests to the server, however, the header of the HTTP request is very long, and the actual transmission of data may be very small, resulting in a waste of bandwidth and serv
1. PrefaceWeb-side IM technology is not easy to implement due to limitations in browser design, and there are roughly 4 main web-end instant Messaging solutions: Traditional Ajax short polling, Comet technology, WebSocket Technology, SSE (Server-sent Events). This article will briefly introduce the principles of these 4 technologies, and point out their similarities and differences, advantages and disadvant
1. PrefaceWeb-side IM technology is not easy to implement due to limitations in browser design, and there are roughly 4 main web-end instant Messaging solutions: Traditional Ajax short polling, Comet technology, WebSocket Technology, SSE (Server-sent Events). This article will briefly introduce the principles of these 4 technologies, and point out their similarities and differences, advantages and disadvant
WebSocket Online test Tool http://ws.douqq.com/1. The connection format is ws://ip/domain name: port (example ws://119.29.3.36:5354)2, for the test environment of the intranet, just fill in the service side of the intranet IP and port3. You can connect to the service-side WS address I provided above to test your own clientThis website supports QQ robot to send message, first add robot qq:625789120 as friend Test1. Friend message Format {"type": "1", "
Html5 websocket example, websocket online chat, php websocket instance, html5websocketWebSocket online test tool http://ws.douqq.com/
1. The connection format is ws: // IP/Domain Name: Port (example: ws: // 119.29.3.36: 5354)2. For an intranet test environment, you only need to enter the Intranet IP address and port of the server.3. You can connect to the server
Explanation and Application of mini-program WebSocket and websocket
Mini-program WebSocket
Instance effect:
What I will talk about todayWebSocketInterface and usage in small programs.
WebSocketWhat is it (brief description)
OfWebSocketInterface and HTML5WebSocketBasically the same, the HTTP protocol is upgraded as a newSocketIt is used on B/S to implement full d
This chapter describes how to use the WebSocket API to control protocols and create applications, and using the existing WebSocket servers provided by http://websocket.org, we can send and receive messages, and create some simple websocket applications. Step-by-step learning to use the WebSocket API, and finally we'll
Overview
HTTP protocol is a stateless protocol, the server side itself does not have the ability to identify clients, must use external mechanisms, such as session and cookies, to maintain a dialogue with a specific client. This is more or less inconvenient, especially in the context of server-side and client needs to continuously exchange data (such as network chat). To solve this problem, HTML5 proposed the browser's WebSocket API.
The primary rol
~Upgrade:websocketConnection:Upgradeis still fixed, telling the client that the protocol is about to be upgraded Websocket , not mozillasocket,lurnarsocket or shitsocket.Then, Sec-WebSocket-Accept this is confirmed by the server, and after the encryption Sec-WebSocket-Key . Server: OK, OK, I'll show you my ID card to prove it.Later, the Sec-
is about to upgrade is Websocket protocol, not mozillasocket,lurnarsocket or shitsocket. Then, sec-websocket-accept this is the server confirmed, and encrypted after the Sec-websocket-key. Server: OK, OK, I'll show you my ID card to prove it. Later, Sec-websocket-protocol is the protocol that represents the final use.
Let's take you to know WebSocket in HTML5 and html5websocket.This article mainly introduces WebSocket in HTML5. This article explains what WebSocket API in HTML5 is, how to use WebSocket API in HTML5, and how to use WebSocket with Socket. IO
(a) WebSocket profileShort Connection : in the traditional HTTP protocol, the client and server side of the communication mode is a short connection, that is, the server side does not maintain a connection with the client, after the message is sent, will disconnect the connection, the next time the client communication, must be established and the server New connection, This is the short connection. In the case of a short link, the client must activel
~Upgrade:websocketConnection:Upgradeis still fixed, telling the client that the protocol is about to be upgraded Websocket , not mozillasocket,lurnarsocket or shitsocket.then, Sec-WebSocket-Accept This is confirmed by the server, and after the encryption Sec-WebSocket-Key . Server: ok, ok, i'll show you my ID card to prove it.later, the Sec-
that represents the end-use.Now that HTTP has done all of its work, the next step is to follow the WebSocket protocol completely. The specific agreement is not elaborated here.You've been so damn websocket for so long, what the hell are you going to do with that, http long poll or ajax轮询 not all of them can deliver real-time information? Well, young m
protocol ~Upgrade: websocketConnection: Upgradeis still fixed, telling the client that the WebSocket protocol is about to be upgraded, not mozillasocket,lurnarsocket or shitsocket.Then, sec-websocket-accept this is the server confirmed, and encrypted after the Sec-websocket-key. Server: OK, OK, I'll show you my ID card to prove it. Later, Sec-
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.