The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Photon Server.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

udp vs tcp for non-realtime

mindlube
2012-07-10 22:39:13

I'm coding for a turn-based game. Pretty much just update the game state, maintain leaderboard, chat messages etc. It's not realtime. What would you recommend? Connect with udp(and use reliable flag for event and operations) or just use tcp? PS I do know what TCP and UDP are... it's just that photon's reliable udp adds a new level of possibility. :ugeek:

Comments

dreamora
2012-07-11 07:32:07

The difference is that with UDP you can decide if you want reliable or if some messages can also be dropped if the line is flooded etc.

If you never need that you can just as well use TCP, might then be the better idea as that hit hw firewalls etc far less commonly

Kaiserludi
2012-07-11 10:39:19

TCP is only implemented as a fallback solution in Photon in case, that one can't use UDP for some reason. Whenever you have the choice, you should prefer UDP, as we can't guarentee, that every Photon feature is supported with TCP.

dreamora
2012-07-11 13:26:33

@Kaiserludi wrote:

TCP is only implemented as a fallback solution in Photon in case, that one can' use UDP for some reason. Whenever you have the choice, you should prefer UDP, as we can't guarentee, that every Photon feature is supported with TCP.

Does that despite websockets, which are even more limited, still hold? I mean aside of the obvious stuff thats protocol based like 'lack of unreliable'

Tobias
2012-07-11 13:33:10

Websockets are TCP only. You have no choice of UDP if you need to use them. TCP is fine and easy but has far less control of how to resolve issues in the network connection. That's why we focus on UDP.

If you feel "at home" with TCP, of course you can use that as underlying protocol with Photon. Our reliable UDP protocol gives you even more control.

dreamora
2012-07-11 17:17:59

I know they are TCP Hence the question on if thats the official stance, that UDP is the way to go and the rest 'just tolerated', cause thats what Kaiserludis posting implied - that didn't make sense given websockets exist on exactly that layer only, as does flash, silverlight, wp7 and any hope for metro support

Kaiserludi
2012-07-11 17:52:03

@dreamora wrote:

I know they are TCP if thats the official stance, that UDP is the way to go and the rest 'just tolerated', cause thats what Kaiserludis posting implied

It was more meant like: On client platforms, on which you have the choice between multiple protocols, UDP is the preferable choice, if there is nothing speaking against it. TCP will work fine, too, for that protocol one just "has far less control of how to resolve issues in the network connection", like Tobias has said, which is more an issue with the protocol on its own, than with Photons support for it: TCP has a more high level approach to sending data over the net than UDP, so we can't tweak low-level stuff as much to suit Photons needs best like we can do with UDP, as TCP already cares about them itself.

dreamora
2012-07-12 06:59:39

Ah then I'm fine

I know that TCP cuts most of the control for its protocol enforced 'QoS' features, but got tricked into believing that above posting was meant to say that there are things that could work on TCP but that are none the less only offered on UDP which does not seem to be the case :)

mindlube
2012-07-18 02:46:14

Interesting- thanks all! Here is how I'm looking at it - as a newb, first game published with Photon.

a) practically all of my operations and events need to be sent reliably b) I actually don't need realtime/twitch low latency I might as well use TCP, and let the interwebs handle the reliability (thanks to the tcp protocol) Rather than using reliable UDP and making my photon server do all the reliability processing. (or is that a negligible amount of cpu?)

On client platforms, on which you have the choice between multiple protocols, UDP is the preferable choice, if there is nothing speaking against it.

I guess the only thing is concern would be user's firewalls at offices and coffee shops etc. If all the big games use Photon UDP... there is no reason why I should not, right?

mindlube
2012-07-18 02:53:05

Actually here is another followup question.

I'm using Unity C# client and targeting Mac OS, iOS and Android.

Does UDP work on all cellular data providers? I would assume so... but haven't actually tried it myself, yet. But that would only be t-mobile prepaid data :shock:

Tobias
2012-07-18 09:16:13

There is always a small margin of users who won't be able to play your multiplayer game in some network or another. Depending on the network they use (e.g. company network), even HTTP might become blocked. Aside from that, UDP and TCP both work fine over mobile networks, too. There are a few Android games out using Photon already.

You will want to minimize the data you send manually. This is cheaper for mobile users but more importantly you improve tolerance in case something goes wrong (network drops something, etc). No matter if you end up with TCP or UDP.

mindlube
2012-07-18 15:40:59

Cool - thanks for explaining. I'm going to use UDP and fallback to TCP.

Back to top