socket 默认堵塞模型:
服务端:
node2:/root/python3#cat t22.py
import socket
import time
EOL1 = b'\n\n'
EOL2 = b'\n\r\n'
response = b'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'
response += b'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'
response += b'Hello, world!'
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serversocket.bind(('192.168.137.3', 8080))
serversocket.listen(10)
connectiontoclient, address = serversocket.accept()
request = b''
while True:
print('11111111111111111111')
print(request.decode())
print('11111111111111111111')
request = connectiontoclient.recv(1024)
print('22222222222222')
print(request.decode())
time.sleep(60)
connectiontoclient.send(response)
connectiontoclie
python socket默认堵塞模型
最新推荐文章于 2022-09-28 23:50:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)