python 如何测试socket连接服务器连接数的极限?并优化改进?
if__name__=='__main__':#一个socket连接sock=[0foriinrange(100000)]forxinxrange(0,100001):t...
if __name__ == '__main__':
#一个socket连接
sock=[0 for i in range(100000)]
for x in xrange(0,100001):
try:
sock[x] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock[x].connect(('192.183.3.223', 10000))
time.sleep(0.01)
print x
except BaseException, e:
print "exception: ", type(e), e
time.sleep(5) 展开
#一个socket连接
sock=[0 for i in range(100000)]
for x in xrange(0,100001):
try:
sock[x] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock[x].connect(('192.183.3.223', 10000))
time.sleep(0.01)
print x
except BaseException, e:
print "exception: ", type(e), e
time.sleep(5) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询