import socket
import time
PORT=8000
address=("192.168.1.105",PORT)
server_socket=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
server_socket.bind(address)
server_socket.settimeout(5)
while True:
try:
data,client=server_socket.recvfrom(1024)
except socket.timeout:
print("chaoshi")
问题:为什么用server_socket.settimeout(5)去设置socket.timeout的异常状态?server_socket.settimeout(5)函数不是应该操作的是server_socket对象吗?为什么会影响socket里面的timeout?