python中什么是文件描述符_windows中select()python中的文件描述符太多

我试图接收到大约1000个到我的服务器的连接,但它不能接收超过512个。如何增加开放连接的数量?我运行的是windows 8.1

不是:我对这些东西很陌生,所以,谢谢你的帮助

这是我的密码import asyncore

import socket

import uuid

import time

import threading

class statistics(threading.Thread):

def __init__(self):

threading.Thread.__init__(self)

def run(self):

while True:

entry = raw_input("")

zaman = int(time.time())

cmd = receivedCmd

print "calculating.."

time.sleep(1)

if entry == 'istatistik':

print str(receivedCmd-cmd) + " command/second"

print "total received commands: " + str(receivedCmd)

entry = ""

class tcpClient:

def __init__(self):

self.clientid = uuid.uuid1(int(time.time()))

self.buffer = ""

self.buffer_size = 0

self.conn_time = time.time()

self.overflow = 0

#print str(self.clientid) + " assingned"

def recv_msg(self, msg):

global receivedCmd

self.buffer = msg

self.buffer_size = len(self.buffer)

receivedCmd = receivedCmd + 1

if self.buffer_size >= 1024:

self.overflow = 1

def __del__(self):

print str(self.clientid) + " has left."

class TCPHandler(asyncore.dispatcher_with_send):

global clist

def handle_read(self):

data = self.recv(1024)

if data:

if clist[self].overflow:

self.send("overflow")

self.handle_close()

else:

self.send(data)

clist[self].recv_msg(data)

def handle_close(self):

del clist[self]

self.close()

def handle_error(self):

del clist[self]

self.close()

class TCPServer(asyncore.dispatcher):

global clist

def __init__(self, host, port):

asyncore.dispatcher.__init__(self)

self.create_socket(socket.AF_INET, socket.SOCK_STREAM)

self.set_reuse_addr()

self.bind((host, port))

self.listen(5)

def handle_accept(self):

self.clist = clist

pair = self.accept()

if pair is None:

pass

else:

sock, addr = pair

#print 'Connection : %s' % repr(addr)

clist[TCPHandler(sock)] = tcpClient()

if __name__ == '__main__':

clist = {}

receivedCmd = 0

server = TCPServer('', 5000)

server2 = TCPServer('',5001)

StaticsThread = statistics()

StaticsThread.start()

asyncore.loop()

注意:使用Twisted框架,我仍然不能接收超过512个连接,我不知道该怎么做。必须有上千个连接的客户端。请帮忙。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值