0

根据我上一个问题的答案,我正在测试XMLPRC模块。在查看文档时,我发现了以下代码行:

server = SimpleXMLRPCServer(("localhost", 8000))

基本上创建一个实例是在我的本地 PC 上SimpleXMLRPCServer收听。port 8000因此,根据文档,客户端将在此代码行中获取服务器地址

proxy = xmlrpclib.ServerProxy("http://localhost:8000/")

我的问题是,如果我想SimpleXMLPRCServer通过 Internet 连接到远程 PC(它有一个使用适当方法运行的实例),我如何从我的客户端 PC 寻址该服务器?

proxy = xmlrpclib.ServerProxy("Address of my server?")

我应该把IP address服务器代替localhost吗?但如果是这种情况,我如何设置我的服务器 PC 使其具有静态 IP 地址而不是普通的动态 IP?

4

1 回答 1

1

An approach - Very high level.

For your remote PC to be accessible over the internet, you need to have a public facing IP address (from your internet service provider) with one of the following configurations:

  • Your server is directly connected to the internet and doesn't sit behind a local area network and can be reached directly using your public facing IP address. - this is usually the case if your system is plugged in to your internet modem.
  • Port forwarding: Set up your internet router (which is public facing) to forward all requests on port 8000 to your internal server on your local network. - This is usually the set up if you use a wireless router.

In either case, you can find your public facing IP address by going to google.com and typing "public ip".

Assuming your internal server can be directly reached using one of the two methods you can access your XMLRPC service using PUBLIC_IP:8000 instead of localhost:8000

于 2014-02-10T03:05:41.653 回答