udp vs tcp for non-realtime

mindlube
edited July 2012 in Photon Server
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

  • 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
  • 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.
  • 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'
  • 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.
  • 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
  • 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.
  • 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 :)
  • 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?
  • 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:
  • 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.
  • Cool - thanks for explaining. I'm going to use UDP and fallback to TCP.