当前位置: 首页>>代码示例>>Python>>正文


Python Address.get_ip_address方法代码示例

本文整理汇总了Python中address.Address.get_ip_address方法的典型用法代码示例。如果您正苦于以下问题:Python Address.get_ip_address方法的具体用法?Python Address.get_ip_address怎么用?Python Address.get_ip_address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在address.Address的用法示例。


在下文中一共展示了Address.get_ip_address方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: from address import Address [as 别名]
# 或者: from address.Address import get_ip_address [as 别名]
 def start(self, addr="0.0.0.0", port=None):
     # Check if radio connected
     destaddr, error = None, False
     assert(self.radioconnected() ), "RadioRx and RadioTx have not been connected to Channel!"
     # Start server
     if port is None: port = self.options.channel_port
     self.impl.start(addr, port)
     # Get server address
     # wait for server and client to start running
     while (not self.impl.server_running() ): time.sleep(0.5)
     while (not self.impl.client_running() ): time.sleep(0.5)
     # should probably update this with correct IP address for matching
     self.addr = self.impl.recv_addr()
     self.port = self.impl.recv_port()
     print "[CHANNEL]: server and client are running, recv_addr =", (self.addr, self.port)
     # Connect to address server and register
     self.addrclient = AddrClient(self.options)
     regaddr, regport = Address.get_ip_address(ifname=self.options.ifname, ntoa=True), self.port
     if (self.addrclient.connect()<0):
         sys.stderr.write("[CHANNEL]: Could not connect with address server!\n")
         error = True
     elif (self.addrclient.register(regaddr, regport)<0):
         sys.stderr.write("[CHANNEL]: Could not connect with address server!\n")
         error = True
     else:
         destaddr = self.addrclient.get_dest_addr()
         if (destaddr < 0):
             sys.stderr.write("[CHANNEL]: Error getting destination address\n")
             error = True
     sys.stderr.write("[CHANNEL]: Destination address = %s\n"%(str(destaddr) ) )
     self.addrclient.close()
     # connect to remote destination
     if not error:
         sys.stderr.write("[CHANNEL]: Connecting  channel client to destination\n")
         self.impl.connect_client(destaddr[0], destaddr[1])
     else:
         self.stop()
         return -1
开发者ID:jmccormack200,项目名称:SDR,代码行数:40,代码来源:channel.py


注:本文中的address.Address.get_ip_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。