Re: 用SocketServer.ThreadingTCPSe rver建的socket服务,能同时支持多少 并发数

LuWen <[email protected]> Thu, 24 Jan 2008 16:21:56 +0800
Newsgroups gmane.comp.python.chinese
Message-ID <[email protected]>
hanzg 写道:

> 正在学习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

hanzg 写道:

正在学习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

reuseaddress选项的问题?

_______________________________________________
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