合集-网络编程
python网络编程之socketio
摘要:服务端: import socketio class ChatServer: def __init__(self): # 创建Socket.IO服务器实例 self.sio = socketio.Server(cors_allowed_origins='*') self.app = socketio
python网络编程之sse
摘要:服务端: from fastapi import FastAPI from fastapi.responses import StreamingResponse from fastapi.middleware.cors import CORSMiddleware import time app =
python网络编程之websocket
摘要:服务端: import asyncio import websockets # 保存已连接的客户端列表 connected_clients = set() async def handle_websocket(websocket): # 将新的客户端添加到已连接客户端列表 remote_addres
python网络编程之tcp
摘要:服务端: import socket import struct sk = socket.socket() sk.bind(('127.0.0.1', 9501)) # 申请操作系统的资源 sk.listen() while True: # print(f'sk:{sk}') # conn里存储的是
python网络编程之udp
摘要:服务端: import socket sk = socket.socket(type=socket.SOCK_DGRAM) # 表示一个udp协议 sk.bind(('127.0.0.1', 9504)) # 服务端不能先发送消息,因为服务端不知道客户端的ip while True: msg, ad
php网络编程swoole http
摘要:服务端: <?php use Swoole\Http\Server; use Swoole\Http\Request; use Swoole\Http\Response; // 创建 HTTP 服务器 server-
php网络编程swoole websocket
摘要:服务端: <?php use Swoole\WebSocket\Server; // 创建 HTTP 服务器 server->on('start',
php网络编程swoole tcp
摘要:服务端: <?php server->set([ 'worker_num' => 8, // worker进程数 cpu1-4倍 'max_request' => 10000, // 根据内存定义 ht
python网络编程之http longpull
摘要:服务端: from flask import Flask, request, jsonify import time app = Flask(__name__) @app.route('/stream', methods=['GET']) def poll(): # 假设这里有一个方法来检查是否有新
转:python的zmq模块
摘要:转自:https://www.jianshu.com/p/04660f746a16https://blog.csdn.net/SweetHeartHuaZai/article/details/126934819 1、zmq介绍: 创建和销毁套接字:zmq.socket(), zmq.close()