开发者

How would I keep a constant piece of data updated through a socket in Python?

开发者 https://www.devze.com 2023-03-09 07:20 出处:网络
I have a client and a server, both written in Python开发者_如何学Go 2.7. Lets say I wanted to make a multiplayer game server (which I don\'t at the moment but I\'m working towards it). I would need t

I have a client and a server, both written in Python开发者_如何学Go 2.7.

Lets say I wanted to make a multiplayer game server (which I don't at the moment but I'm working towards it). I would need to keep the server up to date (and other clients) on my characters whereabouts, correct?

How would I do this with sockets? Send or request information only when it is needed (e.g the character moves, or another players character moves and the server sends the information to other clients) or would I keep a constant socket open to send data real-time of EVERYBODY's movement regardless of if they have actually done something since the last piece of data was sent or not.

I won't struggle coding it, I just need help with the concept of how I would actually do it.


With TCP sockets it is more typical to leave the connections open, given the teardown & rebuild cost. Eventually when scaling you will do look into NewIO\RawIO.

If you do not, imagine that the game client might take a step & not get confirmation if sending it to the server & other players.


Definitely keep the socket open, but you should consider using something like ZeroMQ which gives you more kinds of sockets to work with.

0

精彩评论

暂无评论...
验证码 换一张
取 消