python - Encoutering OSError: [WinError 10038] 使用 python 设置基本 http 代理时,尝试对非套接字的操作进行操作
问题描述
我试图使用 python 设置一个简单的 http-proxy,但我不断收到 OSError: [WinError 10038] An operation was trying on something that is not a socket ondata = conn.recv(1024)
我究竟做错了什么?我的主要功能
def main():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
s.listen()
while True:
conn, addr = s.accept()
# get the next valid HTTP request
buffer = b''
while True:
with conn:
print('Connected by: ', addr)
data = conn.recv(1024)
if not data:
break
buffer = buffer + data;
req, buffer = parse_message(buffer)
if req is not None:
print('success');
解决方案
推荐阅读
- javascript - 无法访问烧瓶中的图像
- php - 如何将数组从控制器发送到可邮寄的降价模板并使用 Laravel 在表格组件中循环?
- java - 动态 Web 项目中没有 javax
- c# - JSON Schema - 无法将数组转换为布尔值
- apache-kafka - Kafka Streams 在集群上处理超时
- amazon-web-services - 未托管在本地计算机上时如何配置 elasticsearch.yml 和 enterprise-search.yml
- mysql - 根据列值连接两个表
- azure - 不支持 KeyVault 备份
- css - Tailwind CSS 徽标居中
- java - Hazelcast 成员不共享嵌入式拓扑中的条目