def net_init(self): (self.exp_rep, self.exp_rep_addrs) = self._init_socket([], zmq.REP) # (self.exp_pub, self.exp_pub_addrs) = self._init_socket( # [], zmq.PUB) # self.exp_pub.setsockopt(zmq.LINGER, 0) self._all_sockets.append(self.exp_rep) # self._all_sockets.append(self.exp_pub) tcp_port = int(net.server_tcp_proxy_port()) self._tcp_proxy_thr, tcp_port = twisted_tcp_handling.run_twisted_server( ('0.0.0.0', tcp_port), self.ctx, self.rep_addresses[0]) self.tcp_addresses = [(self.my_ip(), tcp_port), (socket.gethostname(), tcp_port)] super(OBCIServer, self).net_init()
def net_init(self): (self.exp_rep, self.exp_rep_addrs) = self._init_socket([], zmq.REP) # (self.exp_pub, self.exp_pub_addrs) = self._init_socket( # [], zmq.PUB) # self.exp_pub.setsockopt(zmq.LINGER, 0) self._all_sockets.append(self.exp_rep) # self._all_sockets.append(self.exp_pub) tcp_port = int(net.server_tcp_proxy_port()) self._tcp_proxy_thr, tcp_port = twisted_tcp_handling.run_twisted_server( ("0.0.0.0", tcp_port), self.ctx, self.rep_addresses[0] ) self.tcp_addresses = [(self.my_ip(), tcp_port), (socket.gethostname(), tcp_port)] super(OBCIServer, self).net_init()
ip, port = contact.tcp_addrs[0] _try_join_experiment(ip, port, "lame_test_script") def _try_join_experiment(host, port, peer_id): trials = 5 msg = mtool.fill_msg("join_experiment", peer_id=peer_id) success = False while not success and trials > 0: result = send_and_receive(host, port, msg) if result is None: print("damn this network, could not contact experiment") elif result.type == "rq_error": if result.err_code == "mx_not_running": print("Multiplexer has not yet started!") elif result.err_code == "peer_id_in_use": print("PEER ID already exists.") break else: print("SUCCESS") success = True time.sleep(0.3) trials -= 1 if __name__ == '__main__': get_eeg_experiments('127.0.0.1', int(net.server_tcp_proxy_port())) # '172.16.53.135' get_eeg_amplifiers('127.0.0.1', int(net.server_tcp_proxy_port())) # '172.16.53.135' # 59336
def _try_join_experiment(host, port, peer_id): trials = 5 msg = mtool.fill_msg("join_experiment", peer_id=peer_id) success = False while not success and trials > 0: result = send_and_receive(host, port, msg) if result is None: print "damn this network, could not contact experiment" elif result.type == "rq_error": if result.err_code == "mx_not_running": print "Multiplexer has not yet started!" elif result.err_code == "peer_id_in_use": print "PEER ID already exists." break else: print "SUCCESS" success = True time.sleep(0.3) trials -= 1 if __name__ == '__main__': get_eeg_experiments('127.0.0.1', int(net.server_tcp_proxy_port())) #'172.16.53.135' get_eeg_amplifiers('127.0.0.1', int(net.server_tcp_proxy_port())) #'172.16.53.135' #59336