1 def dedicated_server():
7 s.bind(("0.0.0.0", 4562))
11 debug("Got white player")
13 g = subprocess.Popen(["python", "qchess.py", "@network::"+str(4700+len(games)), "@network::"+str(4700+len(games)), "--log="+"_".join(str(datetime.datetime.now()).split(" ")) + ".log"], stdout=subprocess.PIPE)
16 ss[0].send("white " + str(4700 + len(games)-1))
17 ss[0].shutdown(socket.SHUT_RDWR)
23 debug("Got black player")
25 ss[0].send("black " + str(4700 + len(games)-1))
26 ss[0].shutdown(socket.SHUT_RDWR)
29 s.shutdown(socket.SHUT_RDWR)
32 while len(games) > max_games:
33 ready = select.select(map(lambda e : e.stdout, games),[], [], None)
35 s = r.readline().strip(" \r\n").split(" ")
36 if s[0] == "white" or s[0] == "black":
44 s.connect((addr, 4562))
46 [colour,port] = s.recv(1024).strip(" \r\n").split(" ")
48 debug("Colour: " + colour + ", port: " + port)
50 s.shutdown(socket.SHUT_RDWR)
54 p = subprocess.Popen(["python", "qchess.py", "@human", "@network:"+addr+":"+port])
56 p = subprocess.Popen(["python", "qchess.py", "@network:"+addr+":"+port, "@human"])