Use boost to encapsulate a websocketserver class

Based on the modifications made on the boost official website case, the implementation of the following specific functions should be based on the specific application scenarios. boost version:1.77 Function: websocket server side, able to handle multiple clients and obtain the url path of their clients Websocket.h #pragma once #include <iostream> #include <unordered_set> #include <boost/beast.hpp> #include […]

python-Socket based on UDP communication, use of socketserver module

1. Sockets based on UDP protocol communication UDP has no link, so whichever end is started first will not report an error. import socket server=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) server.bind((‘127.0.0.1’,8082)) while True: data,client_addr=server.recvfrom(1024) print(data) server.sendto(data.upper(),client_addr) server.close() server import socket client=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) while True: msg=input(‘>>: ‘).strip() client.sendto(msg.encode(‘utf-8’),(‘127.0.0.1’,8082)) data,server_addr=client.recvfrom(1024) print(data) client Since UDP has no connection, multiple clients can communicate with the […]

Use of WebSocketServer (@ServerEndpoint)

Front-end code function initWebSocket() {<!– –> if (typeof WebSocket == “undefined”) {<!– –> console.log(“Your browser does not support WebSocket”); } else {<!– –> console.log(“Your browser supports WebSocket”); //Implement the WebSocket object, specify the address and port of the server to connect to establish a connection //Equivalent to socket = new WebSocket(“ws://localhost:8083/checkcentersys/websocket/20”); var wsPathStr = wsPath […]

Socket and socketserver for python3 socket programming (TCP and UDP communication)

Socket and socketserver are socket communication modules in python3, and their use is summarized as follows. Directory 1. socket 1.1 Module introduction 1.2 Socket acquisition 1.3 socket interface 1.3.1 Server 1.3.2 Client socket functions 1.3.3 Public socket functions 1.3.4 Lock-oriented socket method 1.3.5 File-oriented socket functions 2. socket server 3.TCP 3.1 socket type TCP 3.2 […]

[Eleven] socketserver achieves concurrency

【Eleventh】socketserver realizes concurrency Based on tcp socket, the key is two loops a link loop a communication loop The socketserver module is divided into two categories: server class (to solve link problems) and request class (to solve communication problems) server class: request class: Take the following code as an example to analyze the socketserver source […]

QT realizes the communication between WebsocketServer and WebsocketClient

Overview WebSockets is a web technology that provides a full-duplex communication channel over a single TCP connection. In 2011, the IETF standardized the WebSocket protocol as RFC 6455. The QWebSocket provided by Qt can be used for both client applications and server applications, and most of the interfaces are consistent with QTcpSocket. QWebSocket currently does […]