#server.py from gevent import monkey;monkey.patch_all() import socket import gevent sk = socket.socket() sk.bind(('127.0.0.1',8080)) sk.listen() def talk(conn): conn.send(b'hello') print(conn.recv(1024).decode('utf-8')) conn.close() while True: conn,addr = sk.accept() gevent.spawn(talk,conn) sk.close() #client.py import socket sk =socket.socket() sk.connect(('127.0.0.1',8080)) print(sk.recv(1024).decode('utf-8')) msg = input('>>>'.encode('utf-8')) sk.send(msg) sk.close()
相关文章
- Python并发编程协程(Coroutine)之Gevent
- python之socketserver实现并发
- Python并发编程06 /阻塞、异步调用/同步调用、异步回调函数、线程queue、事件event、协程
- 【python进阶】并发编程-线程\进程\协程
- Generator(生成器),入门初基,Coroutine(原生协程),登峰造极,Python3.10并发异步编程async底层实现
- Python并发编程-IO模型-IO多路复用实现SocketServer
- Python3 与 C# 并发编程之~ 协程篇
- Python 之网络编程之socket(2)黏包现象和socketserver并发
- python利用socketserver实现并发套接字功能
- python基于socketserver实现并发,验证客户端的合法性