def __init__(self, game, addresses, port, versionString, adminPassword): self.game = game self.versionString = versionString self.shutdownOrder = False self.adminPassword = adminPassword self.rawConnections = [] self.playerCons = [] self.sockets = [] self.updating = {} self.socketsOpened = [] self.listening = False ### open listener sockets for address in addresses: try: socket = SocketType() socket.setblocking(0) socket.bind((address, port)) socket.listen(10) socket.setblocking(0) print "opened socket on %s:%i" % (address, port) self.sockets.append(socket) self.socketsOpened.append(address) self.listening = True tSocket = Thread(name="socket on %s:%i" % (address, port), target=self.threadListener, args=(socket, )) tSocket.start() except Exception, ex: print "failed to open socket on %s:" % address, ex[1]
def __init__(self, server="localhost", port=config.port, password=None): self.server = server self.port = port if password: self.password = md5(password).hexdigest() else: self.password = None self.socket = SocketType()