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")
评论列表
文章目录