Best practice for online client-server interaction online for multiple connections

I tried to read many forums, articles, but still do not know which one to choose.

Consider a small multi-player puzzle, the client runs on an Android device. A server is a dedicated rented computer with a Win server. Let's say one game consists of 3 players (ABC). When 3 players are ready, the game begins: the server sends a notification "currentPlayer = A" to ABC. By telephone A becomes reproducible, BC is blocked / only bystanders. When A done sends "next" to the server, the server sends a notification "currentPlayer = B" to ABC .... so on ...

This is a very simplified model (of course, more communication should happen during the game, since BC wants to see what A does when they are blocked / observers, etc.) - but enough for my question.

I need a bidirectional communication platform . The information to send is usually small, but occurs quite often, so there is no need for a lot of overhead for each message, so I assume that a permanent connection looks what I need.

Based on the HTTP data, there can be no question, since this is only a client โ†’ Server. Well, I can periodically ask what is the current state of the game for each Client, but this is terrible. Also here I need to establish a connection before each request, it looks too much.

Then I thought of sockets . They are always connected (fast connection, permanent connection). It looks fine, but the problem is, if I have 100K games, it's 300K connectors. But the AFAIK server can handle max ports / address 65K. This is not enough. Not to mention that this will mean 300K streams on the server (stream for each socket connection). Is there a regular computer that can handle this? The server does not have game logic, only sending information between players, so there are not many streams.
I was thinking, perhaps, to use several ports, for example, the server accepts 8000-8999, which will mean a connection of 1K * 65K max. And when the client connects, it can choose a random port to connect to balance it. Could this work? However, the thread number may still be a problem on the server, perhaps?

What do you guys think other suggestions fit?

EDIT:
I thought of another idea: what if during the online game I leave the server: one player will be the socket server on his phone (let them say player A), and the rest (B and C) will connect to the phone? The server will be used only for organizing the game, storing points, etc.

thank

+4

All Articles