0

I use python and the socket library to allow communication between 2 PCs. In a local network, everything works perfectly! But now I'm looking to be able to communicate outside my local network... I've been looking on the internet and I've found explanations: you have to create a dmz on my router or do a port forwarding on my router, etc. I was wondering if there was an easier way than to modify my router and how did the instant messengers such as Signal, Skype work? Because for these applications I do not need to modify my router? Sorry for the mistakes, I don't speak English. Small precision I am only 15 years old please be indulgent. Thanks !

My goal here is to retrieve on pc#1 the keyboard keys that are pressed and transfer them to pc#2 with a latency really of the order of a few milliseconds only.

goran
  • 25
  • 6
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jun 26 '22 at 15:30

2 Answers2

0

Routers have whats called a N.A.T. (Network Address Translation) each time you send something to a server a "hole" is opened on the NAT allowing you to receive packets from the server you sent something to. (The server accepts packets on one port that's forwarded from their router).

When using skype you send your message to the skype server, the skype server stores it, and then the other person asks the skype server if it has any messages for him, since he stored your message he sends it to him as a response.

This is what a Server-Client Model Is.

Direct communication (peer to peer) is more complicated and requires more roundabout methods such a UDP Hole punching or other NAT traversal methods.

This question might also help How to communicate between two machines with public IP but both behind LAN(python solution)?

Ftoy
  • 26
  • 6
  • Ok, thank you very much for the explanation! So to have it easier, would it be better if I took an external server? – goran Jun 26 '22 at 15:35
  • Yes, most applications use a port forwarded server to be reliable. – Ftoy Jun 26 '22 at 15:37
0

You have 2 options:

Option 1: Use a VPN, you can use a commercial VPN app as https://www.vpn.net/ or mount your owner VPN server with openvpn, this make a lan between multiple machines.

Option 2 (this is what i would do): mount your socket server in a cloud server, assign the ip of your cloud server as socket server ip for your socket cliente