コード例 #1
0
class CentralServer:
	
	def __init__(self,list_ip):
		self.sock=ServerSocket()
		self.sock.bindTo("127.0.0.1",50000)
		self.sock.limitListenersTo(4)	
		self.semaphore = threading.Semaphore(1)
		threading.Thread.__init__(self)
		self.ip_dict=dict()
		self.ip_list=list_ip
		for ip in ip_dict.keys():
			c=ClientSocket()
			c.connect(ip,49999)
			self.ip_dict[str(ip)]=c

	
	def createThread(self):
		while True:
			sockObj,ip=self.sock.acceptConnection()
			self.ip_dict[str(ip)]=sockObj
			self.tReciever=ThreadedReciever(sockObj,ip,self.semaphore,self.ip_dict)
			self.tReciever.start()
		#assuming somehow threads have been created and 
		# and there is a dict generated	
	def start(self):
		
		createThread()
コード例 #2
0
	def __init__(self,list_ip):
		self.sock=ServerSocket()
		self.sock.bindTo("127.0.0.1",50000)
		self.sock.limitListenersTo(4)	
		self.semaphore = threading.Semaphore(1)
		threading.Thread.__init__(self)
		self.ip_dict=dict()
		self.ip_list=list_ip
		for ip in ip_dict.keys():
			c=ClientSocket()
			c.connect(ip,49999)
			self.ip_dict[str(ip)]=c