我试图通过xmlrpc连接两台计算机,但总是收到“[Errno-2]Name or service not known”消息。有时候它管用,有时候却不行,我不知道我做错了什么。这是我正在运行的代码
客户端(在一台计算机上):
from xmlrpclib import ServerProxy
import time
while True:
try:
# robot_file = open("robot_file", "r")
# robot_uri = robot_file.readline()
robot_uri = "http://pototo.local:12345"
print("robot uri: " + robot_uri)
server = ServerProxy(robot_uri)
# robot_file.close()
# os.remove("robot_file")
print('removed robot_file')
break
except BaseException:
print("trying to read robot uri")
time.sleep(1)
pass
print('processing request')
while True:
try:
print (server.getLocationInfo(2))
time.sleep(1)
except BaseException as e:
print("trying to read request")
print (e)
time.sleep(1)
服务器(在另一台地址为“http://pototo.local:12345”的计算机上)
^{pr2}$服务器是一个打算作为一个ROS节点运行的,但是我在这里将它转换回普通的python,以防您想运行它。如果要运行它,请确保相应地更改URI。在
非常感谢
大多数情况下,这个错误仅仅意味着它无法连接到指定的主机。你试过让那些机器正常运转吗?也有可能是python无法解析.local主机(如果我没弄错的话,这是Apple的bonjour协议的一部分),您可能需要使用一个IP地址。在
相关问题 更多 >
编程相关推荐