pupil_remote.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:esys-pbi 作者: fsxfreak 项目源码 文件源码
def start_server(self, new_address):
        self.thread_pipe.send_string('Bind', flags=zmq.SNDMORE)
        self.thread_pipe.send_string(new_address)
        response = self.thread_pipe.recv_string()
        msg = self.thread_pipe.recv_string()
        if response == 'Bind OK':
            host, port = msg.split(':')
            self.host = host
            self.port = port
            return

        # fail logic
        logger.error(msg)

        # for service we shut down
        if self.g_pool.app == 'service':
            audio.say("Error: Port already in use.")
            self.notify_all({'subject': 'service_process.should_stop'})
            return

        # for capture we try to bind to a arbitrary port on the first external interface
        else:
            self.thread_pipe.send_string('Bind', flags=zmq.SNDMORE)
            self.thread_pipe.send_string('tcp://*:*')
            response = self.thread_pipe.recv_string()
            msg = self.thread_pipe.recv_string()
            if response == 'Bind OK':
                host, port = msg.split(':')
                self.host = host
                self.port = port
            else:
                logger.error(msg)
                raise Exception("Could not bind to port")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号