I'm going to make a simple web server game server with Python flask.

Asked 2 years ago, Updated 2 years ago, 66 views

Hello, I'm going to make a simple game server using Python Flask. I even sent and received data to the server when I sent the input, but I want to synchronize it with other users, but is it possible to make it synchronized when I didn't send the input in any way?

python flask

2022-09-21 17:53

2 Answers

The http communication can only send requests from clients. The server cannot actively send data. This does not mean that http(s) is not impossible. There's a way to send requests periodically to receive synchronized data. However, this method has a large latency and has a lot of overhead of establishing a server-client connection per request, and there is a lot of unnecessary metadata other than the actual data to be exchanged, resulting in a relatively high amount of communication. If it's the kind of game where real-time situations have to be displayed, the problem gets bigger.

So you have to use socket communication that can communicate in two ways. This is because once a connection is made, communication is possible at a low cost.

Rather than directly dealing with socket-related low-level APIs, I think it would be better to use flask-socket.io.


2022-09-21 17:53

It is most convenient to solve the synchronization problem with websocket.

Because current browsers support websocket, it is the most common solution for server push implementation.

In the past, there was no special alternative, so we used long pooling to implement comet, but not now.

Looking at the documentation on flask-socket.io, it seems that the eventlet is available, so it also supports websocket.


2022-09-21 17:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.