#!/usr/bin/env python
# coding=utf8
# si.hairui, 2016.11.24
# Http Client, Python 2.7.5
import httplib
# 服务器信息
HTTP_SERVER_LIST = [
{'ip': "192.168.0.235", 'port': 80, 'filepath': "/web/video/smartdeer.mp4"},
{'ip': "192.168.0.236", 'port': 80, 'filepath': "/web/video/toystory.mp4"}
]
# 客户端信息列表
HTTP_CLIENT_LIST = [
{'ip': "192.168.0.218", 'port': 7575},
{'ip': "192.168.0.219", 'port': 7575},
{'ip': "192.168.0.220", 'port': 2434},
{'ip': "192.168.0.221", 'port': 2434}
]
# 轮询服务器和客户端发起HTTP请求
for httpServer in HTTP_SERVER_LIST:
for httpClient in HTTP_CLIENT_LIST:
try:
myHttpConn = httplib.HTTPConnection(httpServer['ip'], httpServer['port'],
source_address=(httpClient['ip'], httpClient['port']))
myHttpConn.debuglevel = 0 # 调试模式开关
myHttpConn.timeout = 3 # 设置连接超时等待(单位:s)
if 0 == myHttpConn.debuglevel:
prin
Python Http 多客户端和服务器(串行)
最新推荐文章于 2023-04-08 22:30:53 发布

最低0.47元/天 解锁文章
5751

被折叠的 条评论
为什么被折叠?



