سؤال

Based on the answer on my previous question, i am testing out XMLPRC module. While looking through the documentation, I found this code line:

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

which basically creating an instance of SimpleXMLRPCServer that is listening to port 8000 on my local PC. So, according to the docs, the client will have this code line where it gets the server address

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

My question is, if I want to connect to a remote PC (which has an instance of SimpleXMLPRCServer running with appropriate methods) over the internet, how do I address that server from my client PC?

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

Should i put the IP address of server instead of localhost? But if that's the case, how do i set my server PC up so that it has static IP address instead of normal dynamic IP?

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top