Article 1
In this series, I will describe in detail how to use mochiweb to achieve massive connections and demonstrate how to create a Comet application using Mochiweb, each mochiweb connection is registered by a router that sends messages to different users. A running application can handle 1 million of the concurrent connections, and it is important that we know how much memory is needed to make it work normally.
In the first article:
Build a basi
Pushlet-open-source comet framework
Pushlet is an open-source comet framework. It has a lot to learn from in terms of design and has great reference value for developing lightweight comet applications.
Observer Model
Pushlet uses the observer model: the client sends a request and subscribes to events of interest. The server assigns a session ID for each client as
Ajax persistent connections, or some people refer to comet, are used to connect to the server in XMLHttpRequest mode. After the connection, the server does not instantly write the corresponding data and return the data. The server will keep the connection and wait for an event to notify the client. After the event occurs, the data will be written to the response immediately. At this time, the client will receive the event notification in a fairly "rea
The comet model hosts maintain persistent connections, and the number of connections to a single host can reach one million (currently, the maximum number of connections to a single host can reach about 0.6 million ), netstat does not respond for a long time when calculating the network connection status, but the SS command statistics are relatively fast, but the output is not beautiful enough. This article mainly summarizes the common statistical met
Tell us today about the crash when Adobe Media Encoder cc 2015 starts,Let's look at the phenomenon first. That's it,Then I found a lot of ways on the Internet, some methods are outdated, or because now the new version of Adobe Media Encoder CC 2015 has not supported the online methods. Here are some of the methods I've found, and the way I've solved the problem myself, to share with you.Let's take a look at
Yunxiang online chat rooms provide online chat rooms, webim, online storage, and other services. webim can create groups (unlimited number of users) for free and store chat records online.
Webim Series
We have already used comet to implement a simple webim in step-by-step webim (1). What is the difference between Comet and general web pages, this article describes the differences between the two by writi
PHP Comet push
Set_time_limit (0);Ob_start ();$pad = Str_repeat (' ', 4000);Echo $pad, '';Ob_flush ();Flush (); Send the resulting content to the browser immediately instead of waiting for the script to end.$i = 1;while ($i + +) { Echo $pad, ''; echo $i, ''; Ob_flush (); Flush (); Send the resulting content to the browser immediately instead of waiting for the script to end. Sleep (1);}
This code is copied online, the code is not a
status of the response
Description of the Statustext:http status
Regardless of the content type, the contents of the response body are saved to the responseText property, and for 非XML数据 that matter, the value of the Responsexml property will be null .When a response is received, in general, the status is judged to be 200, which is a sign of the success of this request. At this point, the responseText contents of the property are ready and can be accessed if the content type is correct
, Ajax synchronous submission is valuable? This is not as good as using a form to do synchronous submission, this to specific problems, I mentioned in the previous traditional synchronous submission of HTTP precision control is very poor, if some synchronization request we need more HTTP control then use AJAX better, in addition to the traditional synchronous request response is to overwrite the original page, It is either a new form to receive the response, but the synchronous Ajax is more flex
Comet Discovery Series two "Ajax polling multiplexing Model"write in front: Ajax polling believe that everyone is using, but there is such a problem, if a site at the same time there are a lot of places need to use this poll? Take our website, there is an unread message number reminder, there is a time to load the latest said, yesterday added a full network, and later will have a similar function to add is sure, do you want to create a separate pollin
Comet (Reverse AJAX) is mainly used to maintain a connection with the Server through HTTP persistent connections to implement Server PUSH and bidirectional communication. The following uses an example to learn how to use it.Benefits: 1. Resource Saving and low latency compared with AJAX polling. 2. Compared with webSocket, it is widely used. 1. first, create an empty Asp.net MVC project to add a Controller (the same code can also be used in Asp.net We
cached clients. clear (); // clear the list object after broadcasting}. This completes the first operation. when you enter text in the broadcast and click to send it: the process still passes the web. confing to the asnyhandler class, execute beginpro Cessrequest method. instantiate Class Object: myasynresult receives the string content object through the content that jquery will broadcast. the above is the same as the first run until the addmessage method enters the else send method details: P
Ajax and Comet
Ajax (short for Asynchronous JavaScript + XML)You can request data from the server without detaching (refresh) the page to bring a better user experience.
The core of Ajax technology is the XMLHttpRequest object (XHR ).I. XMLHttpRequest object
/* Compatible with earlier IE versions */function createXHR () {if (typeof XMLHttpRequest! = "Undefined") {return new XMLHttpRequest ();} else if (typeof ActiveXObject! = "Undefined") {// applica
Comet ("Server Push" technology based on HTTP long connections)The Web server sends the data passively to the client, the client requests it, the server responds (sends the data),So the "server push" technique adds quotes.There are two ways to achieve this:1. Ajax-based long polling (long-polling) modeThe browser sends an AJAX request (sets a timeout and processes the returned state,Conjecture: Setting the timeout,connection:keep-alive will be added t
1.prepare front-end code, Meta Content-type cannot be ignored! As to the XHR, status should be 32.back-end, remember to-call, both methods to set time limit to unlimited and cache-control to be no-cache;Comet realization with ajaxphp
were at IP address" + Response.ip + ", which was in" +3Response.city + "," + response.region_name);//try to really can pop up my address!!! 4 }5 6 varScript = document.createelement ("Script"); 7SCRIPT.SRC = "Http://freegeoip.net/json/?callback=handleResponse"; Specifies that the callback function is Handleresponse ()8Document.body.insertBefore (Script,document.body.firstchild);Compared to the picture ping, the advantages of JSONP are:1) Direct access to response text2) supports two-way
When we want to display some data in the browser in real time, how? There are many ways to implement, the simplest is to set an interval, Ajax constantly send requests, this way the most obvious flaw whether or not new data will always send the request, and this interval if set long, timeliness is too poor, If the interval is set short, each client is constantly sending a large number of requests that affect server performance Another is the use of server push technology, based on the way of l
= 1000; Xhr.ontimeout=function() {}xhr.send (NULL) Two: Using the XMLHttpRequest EventProgress Event: The following 6 progress events are available. Loadstart,progress, error, Abort, load, loadend.1) Use Load event optimization:var xhr newfunction() { try{ if ((xhr.statue>=200 xhr.status) {xhr.responsetext}} catch(ex) {// Suppose there is a ontimeout processing event} =thefunction() {}xhr.send (null )Whenever the browser receives a server response, the load event
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.