Ask coding questions

← Back to all posts
Websockets, or webservers?
Dart (1187)

If I wanted to make a game in python that’s text bassed, and I wanted to be able to play with someone else, would it be better to use a web server or websocket to communicate data?

Answered by Baconman321 (1059) [earned 5 cycles]
View Answer
Baconman321 (1059)

Websockets are quite worth it. That said, it really depends. If your game periodically sends data, you could always go for long polling (AJAX requests periodically).

Web sockets allow connections between the server and the client without having to send additional headers each time a message is sent.

Websockets are most of the time used for games, so yes I would definitely recommend websockets.

Dart (1187)

@Baconman321 very helpful, thank you :)

Baconman321 (1059)

@Dart If it's in the terminal, then you can use network sockets instead. They support UDP, which sends info rapidly without guarantee of the info being received and in order. It sounds bad, but for fast-paced games it is perfect.

Dart (1187)

@Baconman321 im planning on making a clone of uno actually so it doesnt have to be lightning fast

Baconman321 (1059)

@Dart TCP will work fine for you then.