sockets - UDP for multiplayer game -


i have no experience sockets nor multiplayer programming.
need code multiplayer mode game made in c++. it's puzzle game game mode not turn-based, it's more cooperative.
decided use udp, i've read tutorials, , samples find decribes how create client sends data , server receives it.
game played 2 players, , both send , receive data to/from other.

do need code client , server?
should use same socket send , receive?
should send , receive data in same port?

thanks, i'm kind of lost.

do need code client , server?

it depends. 2 player game, both computers on same lan, or both on open internet, have 2 computers send packets each other directly.

on other hand, if want game work across internet, when 1 or both players behind nat and/or firewall, have problem nat and/or firewall filter out other player's incoming udp packets, unless local player goes trouble of setting port-forwarding in firewall... many users not willing (or able) do. in case, might better off running public server both clients can connect to, forwards data 1 client another. (you might consider using tcp instead of udp in case, @ least fallback, since tcp streams in general have fewer issues firewalls udp packets)

should use same socket send , receive? should send , receive data in same port?

you don't have to, might -- there's no downside using single socket , single port, , simplify code bit.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -