Client-server interaction comparison vs. native instances (compare Ajax,server-sent event,websocket/netsocket)

Source: Internet
Author: User

Yesterday, I learned the native instance of WebSocket, and found it necessary to compare several common client-server-side no-refresh interaction forms:

First, Ajax: The client determines when to proactively send requests to the server side

such as: No refresh comments, no refresh change pictures.

The primary purpose is to not refresh the customer experience, but it is the client's action to trigger a request to the server.

Example online many, native JS or encapsulated Jqurey are more commonly used, easy to understand, easy to modify the way of self-help.

Second, Server-sent event: Scheduled by the Server side to the Client push content

such as: Push the stock market dynamics per second, push the sports match text broadcast every second.

The feature is that the client only needs to send a "come, please ravage me" request (can open the page automatically send, reduce user action), the server is scheduled to push. The disadvantage is the consumption of traffic.

Native instance can refer to W3school: Server send event (http://www.w3school.com.cn/html5/html_5_serversentevents.asp)

Third, socket network communication: The two sides equal, free interaction, I want to send you when you need to receive

such as: Chat scenes.

Characteristic is the province flow, when the client wants to send on the hair, when the server side wants back on the back, both sides have the listener socket in charge.

The first thing I learned was. NET Socket, which is a. NET Framework-based network communication, a generic instance of a console program or WinForm.

Yesterday new contact WebSocket, and net socket main difference is facing the browser side (with the web so called websocket), need HTML5 support, browser support (Ie10 above, the latest FF, Chrome support, I heard that safari once thought this technology was not safe to temporarily cancel the support), the most unfortunate is the need. net4.5 and above can be, namely:. net4.0 is no System.Web.WebSocket this namespace (do not know if the other DLL is not used)-- However, WinServer2003 supports up to. net4.0 ...

The UI continues to use the Web (HTML+JS) to send the WS-Protocol request to the console program, using the Web Form and the Socket:netsocket to make the console program net4.0.

Native Instance reference: Leo's (http://www.cnblogs.com/Leo_wl/archive/2013/04/12/3016063.html), the article mentions the above form, there is only one clerical error: getseckeyaccept () The string appended to the method is less than a "-" (before E914). It should be: byte[] encryptionstring = SHA1. Create (). ComputeHash (Encoding.ASCII.GetBytes (key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"));

The author also wrote an example demo, support multiple open web to the same server to communicate, please see the author "online Ghost Hunt" series of SVN code:

SVN address: https://115.29.246.25/svn/Catghost/Account: Guest Password: Guest

12th Version log:

1. Simulate server-side: Start Netsocketdemo.server Project

2. Impersonate a client: Access the demo40.html page of the Catghost.websocketdemo project (can be opened multiple)

Iv. Other Keywords: SignalR (server push), polling, socket4net (client encapsulation), SuperSocket (server-side encapsulation)

In the process of learning to meet more other keywords, listed for the reader to expand learning.

SIGNALR has not learned that polling is a conceptual understanding.

Socket4net is the client package for the socket: http://websocket4net.codeplex.com

SuperSocket is the server-side package for the socket: http://superwebsocket.codeplex.com

Client-server interaction comparison vs. native instances (compare Ajax,server-sent event,websocket/netsocket)

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.