def __init__(self, host, port):
        ConnectionSocket.__init__(self)

        self.host = host
        self.port = port

        self.connected = None
        self.data = None
Exemple #2
0
    def __init__(self, host, port):
        ConnectionSocket.__init__(self)

        self.host = host
        self.port = port

        self.connections = {}
        self.connection_inputs = [self.socket]
        self.connection_outputs = []
        self.message_queues = {}

        try:
            self.socket.bind((self.host, self.port))
            self.socket.setblocking(False)
            log.info("Listening on %s:%s" % (self.host, self.port))
        except socket.error as err:
            log.critical(err[1])
            sys.exit(1)

        self.socket.listen(5)
    def __init__(self, host, port):
        ConnectionSocket.__init__(self)

        self.host = host
        self.port = port

        self.connections = {}
        self.connection_inputs = [self.socket]
        self.connection_outputs = []
        self.message_queues = {}

        try:
            self.socket.bind((self.host, self.port))
            self.socket.setblocking(False)
            log.info("Listening on %s:%s" % (self.host, self.port))
        except socket.error as err:
            log.critical(err[1])
            sys.exit(1)

        self.socket.listen(5)
    def connect(self):
        try:
            if self.connected == False:
                sleep(1)
            ConnectionSocket.__init__(self)
            self.socket.connect((self.host, self.port))
            self.connected = True

            log.info("Connected to %s:%s" % (self.host, self.port))
            signals.emit('connection:connected', self)
        except socket.error as err:
            if self.connected == False:
                log.critical("Can't connect to %s:%s: %s" % (self.host,
                                                             self.port,
                                                             err[1]))
            elif self.connected or self.connected == None:
                log.critical("Can't connect to %s:%s: %s" % (self.host,
                                                             self.port,
                                                             err[1]))
                self.connected = False

        return self.connected