1
\$\begingroup\$

I saw this subject several times, however I will wish better understand.

I am working on the development of a 2d game like a little MMO. (Currently I only do research). I see people who says it's easier to use TCP for all the game. But is it really viable ?

In my mind, what I would have made is to use UDP in multicast. What about this solution ?

Thank you !

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Generally: Yes, TCP is viable for network communication, and it should be the default choice to implement communication over a network. If you introduce arbitrary undefined constraints, the question becomes unanswerable. To make the question answerable, you need to define the constraints. In other words: As it is, the question is too broad. And if you can narrow it down, it will most likely be a duplicate. \$\endgroup\$
    – Peter
    Jul 20, 2017 at 23:09
  • 1
    \$\begingroup\$ Both :) tcp for important data, which have to be reached at the clients. udp for unreliable things. position update maybe.. \$\endgroup\$
    – Ismoh
    Jul 21, 2017 at 5:39
  • 1
    \$\begingroup\$ Possible duplicate of Is UDP still better than TCP for data-heavy realtime games? \$\endgroup\$
    – Philipp
    Jul 21, 2017 at 7:47

2 Answers 2

1
\$\begingroup\$

For a reasearch project TCP is fine but really most large scale network games use UDP and write some kind of reliable Messaging system overtop. This is done to address some of TCP's shortcomings:

  • Bad latency due to buffering (can be somewhat overcome by disabling nagel algorithm)
  • Bandwidth-heavy guaranteed delivery mechanism
  • Stream based API means messages are blocked until previous messages are sent, even if they are old
  • No way to have application-defined priority of messages that can be thrown away if packet loss occurs

As for multicast - it doesn't work reliably in the wilds of the internet so is not realistically useful.

Gaffer Games has great details on this stuff.

\$\endgroup\$
-6
\$\begingroup\$

I would use TCP because UDP is not guaranteeing that your data will be correctly received, there is no way to check that because UDP is not connecting with other clients, it only sends data.

TCP server can listen to the port, so if another host will trying to connect and send data to it, you can check that.

UDP is old and for game TCP is better, you can do multicasts too, storing clients in some data container and next sending data to them all via loop.

\$\endgroup\$
3
  • \$\begingroup\$ "UDP is old": So is TCP. "For games TCP is better": Unless it isn't, depending on the game/application. "TCP can do multicast": Not if you use the more common definition of multicast. "There is no way to check": Unless you implement one of many ways that allows checking. \$\endgroup\$
    – Peter
    Jul 20, 2017 at 23:15
  • \$\begingroup\$ @Peter For MOST games TCP is better because of reasons that I gave. I am talking about not implemented by yourself ways of checking that the data was received. Of course, there are many ways to check that the data is received, like they are many ways to write a game, but will you use ways that don't have implemented useful things by default like libraries or engines to write that from scratch? \$\endgroup\$
    – Michael
    Jul 21, 2017 at 2:06
  • \$\begingroup\$ I'm not saying you're completely wrong. I'm saying this level of detail with vague and over-generalized statements (" for game TCP is better", "there is no way to check that") doesn't provide the kind of value a good answer needs to provide. You did put in some effort that's why I upvoted another question of yours, but I don't think this answer is particularly helpful. \$\endgroup\$
    – Peter
    Jul 21, 2017 at 12:46

Not the answer you're looking for? Browse other questions tagged .