Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.
Python Network Question: How can I get my client to connect over the net?
I followed a pretty basic tutorial on Sockets, and wrote a small script that allows me to connect over LAN to another computer, and I can connect to myself on my own computer (Little pointless)
The problem is that I need it to connect over the internet to the client piece of software I wrote. Except the client can never find my connection.
This is where I get confused, he obviously cannot enter in my local IP, as it doesn't exist on his network. He's going to have to use my routers external IP.
But then how, will the client be able to know which computer to connect to when he enters the external IP of my network, there could be 3-4 different computers on it.
I have it so that I define the port he is to connect over, except despite having the same ports entered in, nothing worked.
Can someone help?
eh, I guess you do have a point.
Thanks for that.
4 Antworten
- husoskiLv 7vor 8 JahrenBeste Antwort
The server side must be reachable from the Internet. The details depend on how the server is connected. If it's on a DSL/cable modem, directly connected without a router, then all you need is to know your IP address and use a port that's not blocked by either your internet provider, or by firewall software on your computer. If that's your setup, check your firewall settings to make sure that incoming connections on that port are allowed. Even if it's not your setup, you still need to do that if you run a firewall.
If you use a router (most people do, these days, if only for the wireless), then that is a computer that acts as the primary network device attached to your modem. It redirects all traffic from computers in your home through that one IP address.
Outgoing client connections are handled transparently. The router has the local IP/port of the client from the connect request, plus the Internet IP/port of the server and can translate packets on the fly. (That's called Network Address Translation, or NAT.) All home routers are NAT routers.
Inbound connections are different because the router only sees its IP address plus a port number. That's not enough information to send packets to the correct computer on your home network. You supply the information with "port forwarding", which nearly all home routers support. Sometimes it is given a different name (I had a GigaFast for years that called it "virtual server"). Go to your modem's setup page with a browser and look around.
There's often an option to set up a default computer to receive all incoming request not explicitly forwarded elsewhere. (For no obvious reason, it's called a "DMZ" by some modems.) Use that with care, if at all, since that exposes every open port on the "DMZ" computer to the Internet. You've just lost the "hardware firewall" function of the router on that computer, so a software firewall is a Real Good Idea. Better is to just forward the ports or port ranges you need.
For specifics, check the router docs, or web search for "port forward" plus your router name and model. Also check docs for "firewall settings" on your OS version or distro.
- Daniel RLv 6vor 8 Jahren
This isn't really a Python question.
You'll need to configure your tier to forward that port to the right computer. Pretty much all routers have an option to do this somewhere on their admin interface.
- KaydellLv 7vor 8 Jahren
@husoski seems quite knowledgable about getting your Python program be be available over the Internet.
You could redevelop your code to work from a web-host on the Internet. My web hosting service says that they support Python.
- Anonymvor 7 Jahren
Well
The most famous peer to peer program for file sharing is Emule. If you dont have it you find it here http://bit.ly/1Aymdaz
Give it a try.
Hope it helps.