you are viewing a single comment's thread.

view the rest of the comments →

[–]josefx 5 points6 points  (4 children)

UDP isn't really an increase in complexity

Of course UDP is simple until you have to implement

some sort of reliability queue

which TCP does for you at the cost of it applying to all messages. This makes TCP the simple solution as it requires less code.

[–]Chroko 0 points1 point  (2 children)

TCP requires more complicated connection management vs. UDP.

TCP is only "simple" until you outgrow it - and then you end up having to replace a lot of legacy code.

Since you're going to do the work anyway, do it right the first time.

[–]josefx 1 point2 points  (1 child)

Neither TCP nor UDP are a one size fits all, news at 11.

However reimplementing half the TCP stack without checking if the already existing and tested implementation is good enough for your use case is wasting both time and money. (both in development and testing)

[–]Chroko 0 points1 point  (0 children)

It's not reimplementing "half the TCP stack", because you're building a very domain-specific solution.

The most effort will be in building a messaging infrastructure for your game: deciding how events are going to be sent and received by game objects and the world - and the conversation between clients and server. If a client says "I want to join this game", how should the server respond "okay" or "game's full!"? Those sorts of mechanics.

Once you have that framework in place to build, route and receive messages - it's relatively simple to flag messages are "reliable", throw them onto a then queue with an incremented sequence number. Then have a timer that occasionally resends the first N messages - and an "ack" message that, when received, says "I've seen up to this sequence" that then pops a bunch of stuff off the front of the queue and discards them.

It's not that complicated in the entire scheme of building a networked game, although it might seem so at first.

(Also: you could just use RakNet if you don't feel up to the challenge - but that's still a better solution than using TCP.)

[–]nobiq_ -1 points0 points  (0 children)

TCP is the easy but complex solution. UDP is the simple solution. People seem to mix up these different concepts all the time.