ice的远程服务,Service端没什么区别,主要是Client端添加一个参数
区别如下已标红:
import sys, Ice
import Demo
with Ice.initialize(sys.argv) as communicator:
base = communicator.stringToProxy("SimplePrinter:default -h 192.168.1.2 -p 10000")
printer = Demo.PrinterPrx.checkedCast(base)
if not printer:
raise RuntimeError("Invalid proxy")
print(printer.printString("Hello World!"))
-p 是指port,端口,-h是指host,主机地址。非本机的话调用要填上主机地址,然后直接用。