information is excerpted from Wikipedia (HT T P S://z H. w i ki p e d i a. o r g/w I ki/w e b so cket)
Simply put, WebSocket is to reduce the number of connections between client and server, reduce system resource overhead, only need one HTTP handshake, the entire communication process is established in a connection/state, also avoids the non-state of HTTP, the service side will remain connected with the client, Until you close the request, at t
Poco WebSocket Library Features:
1, create WebSocket client using Http/https clientsession
2, is synchronized, this should be sufficient for C + + desktop programming.
3, rely on OpenSSL.
The code is as follows
Copy Code
#include "stdafx.h"#include #include #include "Poco/net/websocket.h"#include "Poco/net/httpclientsession.h"#include "Poco/net/httprequest.h"#include "poco/net
Poco WebSocket Library Features:
1, create WebSocket client using Http/https clientsession
2, is synchronized, this should be sufficient for C + + desktop programming.
3, rely on OpenSSL.
The code is as follows
#include "stdafx.h" #include #include #include "poco/net/websocket.h" #include "Poco/net/httpclientsession.h" #include "poco/net/httprequest.h" #include "poc
message arrives, when the connection is closed, and when the error occurred. The WebSocket protocol defines two URL schemes, where WS and WSS represent unencrypted and encrypted communication between the client and the server. WS (WebSocket) is similar to HTTP URLs, while the WSS (
("websocketerror!");};The first line of code is to request a WebSocket object, the parameter is the server-side address that needs to be connected, as the HTTP protocol begins, the URL of the WebSocket protocol uses ws://, and the security WebSocket protocol starts with wss://.The second line to the fifth behavior
SslSSL (Secure Socket Layer) is simply a cryptographic technique through which we can establish a secure communication link on both sides of the communication, so that both sides of the data interaction can communicate securely without worrying about the data being stolen. For an in-depth knowledge of SSL, you can read this article: overview of the operating mechanism of SSL/TLS protocolWssWSS is the abbreviation for Web Socket Secure, which is an encrypted version of
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 en
As we all know, the HTTP protocol is stateless and interacts with the server based on Request/response, which is what we often call the single-mode. However, with the development of the Internet, the two-way communication between the browser and the server is increasing, and the way of long polling to the servers to get the latest data and push effect is becoming more and more satisfying. HTML5 Standard, also provides us with the browser and the service side of the Duplex Communication protocol
In HTML5 specifications, my favorite Web technology is the rapidly becoming popular WebSocket API. WebSocket provides a popular technology to replace the Ajax technology we have been using over the past few years. This new API provides a method to effectively push messages from the client to the server using simple syntax. Let's take a look at HTML5 WebSocket API
How to configure https and wss for nginx, nginxhttpswss
How to configure https and wss for nginx
server { listen 443 ssl; server_name localhost; ssl on; root html; index index.html index.htm; ssl_certificate ******.pem; ssl_certificate_key *******.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:
Microsoft Office SharePoint service 2007 is Microsoft's latest enterprise collaboration application and development platform. Moss for short, Moss is developed based on window shareponit service 3.0, and WSS for short. Moss is charged, and WSS is free. you can install WSS for free as long as you have the Windows server2003 license.
WebSocket SecurityThe WebSocket protocol is a young technology, and brings with it some risks. Decades of experience has taught the web community some best practices around HTTP security, but the security best practi Ces in the WebSocket world aren ' t firmly established, and continue to evolve. Nevertheless, some themes has emerged and they is described in this
= new WebSocket ("ws://echo.websocket.org"); Ws.onopen = function () {ws.send ("test!");}; Ws.onmessage = function (evt) {console.log (evt.data); Ws.close ();}; Ws.onclose = function (evt) {console.log ("websocketclosed!");}; Ws.onerror = function (evt) {console.log ("websocketerror!");};The first line of code is to request a WebSocket object, the parameter is the server-side address that needs to be c
client implementation of WebSocket:Listing 5.WebSocket Client API samplevar New WebSocket ("WS:// ws.onopen = function () {ws.send (" test!");}; = function (evt) {console.log (evt.data); Ws.close ();}; = function (evt) {console.log ("websocketclosed!");}; = function (evt) {console.log ("websocketerror!");};The first line of code is to request a WebSocket
In this way, WSS can compete with professional software developers to some extent, because it allows users to create and customize their own websites. in just a few minutes, a user can create a WSS site, add several lists and document libraries, and customize the appearance of the site to meet certain commercial needs. an identical solution, if ASP. NET development, it may take a developer a few weeks or ev
Two URL schemes of WebSocket protocolNon-encrypted traffic between WS client and serverEncrypted traffic between the WSS client and serverWebSocket secure means that WebSocket connections using Transport Layer Security (SSL) use HTTPS security to secure HTTP connectionsConstructors for 1.WebSocketvar ws = new WebSocket
var https=require (' https '), var ws=require (' ws '), var fs=require (' FS '), Var keypath=process.cwd () + '/server.key ';// I put the secret key file in the directory under Run command to test var certpath=process.cwd () + '/server.crt ';//console.log (KeyPath);//console.log (Certpath); var options = { Key:fs.readFileSync (keypath), Cert:fs.readFileSync (Certpath), passphrase: ' 1234 '// If the secret key file has a password, use this property to set the password}; var server=https.create
First create a self-signed certificate using OpenSSL:1024x768 >/path/to/private. PEM//-new -key/path/to/ Private. Pem-out csr.pem//365 - in Csr.pem- signkey/path/to/Private. PEM- out/PATH/TO/FILE.CRTTo create a WSS server using the WS module:varHttps=require ('HTTPS');varWs=require ('ws');varFs=require ('FS');varKEYPATH=PROCESS.CWD () +'/server.key';//I put the key file in the directory running the command to testvarCERTPATH=PROCESS.CWD () +'/SERVER
(ArrayBuffer data );Void send (ArrayBufferView data );};
Create websocket
The Code is as follows:
Ws = new WebSocket (address); // ws: // 127.0.0.1: 8080
Call its constructor and pass in the address to create a websocket. It is worth noting that the address protocol must be ws/wss.
Disable socket
The Co
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.