用SocketServer.ThreadingTCP Server建的socket服务,能同时支持多少并发数
hanzg <[email protected]> Thu, 24 Jan 2008 13:52:52 +0800
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
正在学习python编程
用SocketServer.ThreadingTCPServer建了socket服务端.然后写了个客户端起1000
个线程去访问这个server
def test():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('192.168.0.65', SERVER_PORT))
sock.sendall('1234567890')
recvData = sock.recv(MAX_PACKET_SIZE)
print 'Recv from server', recvData
sock.close()
if __name__ == '__main__':
for i in range(1000):
thread.start_new_thread(test)
time.sleep(0.1)
如果我在服务端的handle(self)中加入很小的延时函数,客户端就报连接拒绝
"socket.error: (111, 'Connection refused')"
我猜想是服务端的并发不够了,怎么才能增加server端的并发数??
_______________________________________________
python-chinese
Post: send [email protected]
Subscribe: send subscribe to [email protected]
Unsubscribe: send unsubscribe to [email protected]
Detail Info: http://python.cn/mailman/listinfo/python-chinese