N
N
Nikolay Alekseev2020-09-03 19:54:42
Computer networks
Nikolay Alekseev, 2020-09-03 19:54:42

How to organize client-server communication if the server does not have a dedicated ip and ports are not forwarded?

The question is more theoretical than practical. That is, I'm not asking you to show me pieces of working code. I just don't understand how it works.

Let's take as an example any game that implies multiplayer. You enter it, negotiate with a friend, create a server. He goes to the list of available servers, sees you, clicks, you connect, everyone is happy.

I worked a lot with client-server applications, and I also have experience in writing network games, but there has always been either a dedicated server or communication was purely local.

And here it is not clear to me, how there is a communication in such cases? Let's say in the local network of the one who decided to become a server there are 3 machines connected via a router. Naturally, no one forwarded the ports in this very router, the user does not have a white IP.
I understand that most likely a dedicated game server, which stores and displays a list of all available game servers, serves as some kind of layer between clients and, when trying to connect, pokes them at each other with the words "now you are friends", but how is this implemented with technical point of view, I do not understand and even more than that, I do not know how to google. Because, I think, the problem is trivial and the answer is on the surface.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
E
egor_nullptr, 2020-09-03
@VariusRain

Start with this article https://en.wikipedia.org/wiki/Hole_punching_%28net...

D
delfer, 2020-09-04
@delfer

https://github.com/fatedier/frp
You need to raise the server anywhere where you can expose the port to the outside, connect clients to it. Further, between clients, you can raise p-to-p connections and forward ports.

G
GavriKos, 2020-09-03
@GavriKos

You've mixed a "game server" that counts the logic, and a server that's a machine available to all opponents. So, the game server can really be both dedicated and running on one of the clients.
But for clients to see each other without port forwarding and other things, you need a server that will be directly available to all machines. Again, they can be one of the clients, or they can be a conditional machine somewhere on the Internet. And in this case, this machine will only act as a proxy - i.e. transfer packets between all clients and the game server.
For the same unit, you can look at the photon - it just provides this proxy.

R
Roman, 2020-09-04
@scripterasm

VPN

D
Drno, 2020-09-05
@Drno

For the first connection, an intermediate and accessible proxy on the internet is used.
Next, he sets up a connection between the two players, and then the players communicate directly.
One of the p-2-p technologies
Ports for players open to each other automatically, using UPNP technology

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question