   TCP or UDP? I dont get it anymore :(
  Hey all,I'm starting an MMORPG(like world of warcraft, runescape, silk road etc etc), and I'm just at the network-protocolling stuff.I've rode the FAQ about it, but I'm still confused about what to use: TCP or UDP?Can someone explain me what to use, and why to use it? In full detail?If you need more explain about the game, feel free to ask. Thanks in advance,Quil   
  Just use TCP. UDP just isn't advantageous enough for most things. Sure with TCP you'll have to have a socket per player but it's not that big of a deal.Also this sounds like you haven't done networking before. Start smaller. Make some tests. If you go for an mmo game you'll probably end up wasting time and energy. Make a few small multiplayer games(2d with debug rendering). If you don't you'll regret it (maybe).   ;  In order to understand which protocol you need to use, you need to understand why both are used and what advantages/disadvantages they both have.UDP offers no guarantee to the ULP that messages will be delivered, or in which order. In short UDP is stateless, you fire a packet and forget about it.TCP on the other hand does offer reliable delivery and order to the ULP. TCP has numerous algorithms and "funkyness" to ensure this, the big downside of this is that each time you send a packet, you have to wait for the target to acknowledge receipt, if it doesn't you have to send it again. What this means is that in essence other packets can "back-up" if they were sent later but did arrive (remember TCP offers guaranteed order).Most games still use UDP, and where required will often build their own reliabilty system for important packets. In many cases you simply don't care if your packets come in, or in what order. For instance, you often want the "last" position, as opposed to the positions in the order they were sent. You can attach an ID to each packet to determine if you've seen one newer than the one you just received.Of course, some games have connections of both types for different purposes.I hope that brief description helped.[Edited by - Adus on May 15, 2009 6:50:13 AM];  You're starting an MMO, and have questions about TCP vs UDP? Great! I suggest you read the answer to question 0 in the Forum FAQ, which will give you a lot of good advice. Then you can continue with the other questions, which will probably contain a lot of other information that you'll end up needing. Good luck!;Quote:Original post by hplus0603You're starting an MMO, and have questions about TCP vs UDP? Great! I suggest you read the answer to question 0 in the Forum FAQ, which will give you a lot of good advice. Then you can continue with the other questions, which will probably contain a lot of other information that you'll end up needing. Good luck!Heya funny guy,I believe in what he's doing.He is only asking which one's better, because you see now that sirisian says "TCP!" and Adus says "UDP!" he's worrying for a long time for this, read much articles about but still wasn't sure.Now he's searching for advice, what's wrong with that?Greetz.   ;Quote:Original post by WugglesQuote:Original post by hplus0603You're starting an MMO, and have questions about TCP vs UDP? Great! I suggest you read the answer to question 0 in the Forum FAQ, which will give you a lot of good advice. Then you can continue with the other questions, which will probably contain a lot of other information that you'll end up needing. Good luck!Heya funny guy,I believe in what he's doing.He is only asking which one's better, because you see now that sirisian says "TCP!" and Adus says "UDP!" he's worrying for a long time for this, read much articles about but still wasn't sure.Now he's searching for advice, what's wrong with that?Greetz.I think the point hplus was trying to make is that if you need to ask that question you're not really in a position to make something as ambitious as an MMORPG.As for UDP vs TCP it depends almost entirely on the requirements of the game, If most data becomes obsolete rapidly you want to use UDP, If data needs to arrive in the right order you want TCP. (for action heavy games UDP is normally the way to go, since any data that TCP resends for you is too old to be useful)   ;  As the first reply said, tcp is fine for mmos.in age of conan we use tcp and have no problems with it.   ;Quote:Original post by Wugglesand Adus says "UDP!" I'd like to point out that I did not say to use UDP, I simply explained what the disadvantages and advantages of both approaches are, and said that "most" games still use UDP. I'd be inclined to agree with Sirisian and _Kami_ that TCP is probably going to be fine for most MMO environments and is much easier.   ;Quote:Original post by _Kami_As the first reply said, tcp is fine for mmos.in age of conan we use tcp and have no problems with it.This isn't 100% accurate, TCP is fine for some mmos , its far less suited for an mmo like planetside than it is for an mmo like aoc or wow. (DaoC uses both UDP and TCP btw)One other option that hasn't been mentioned yet is to just run with something like RakNet which simplifies alot of things and also allows you to easily send reliable and ordered packets over UDP.   ;Quote:Original post by SimonForsmanThis isn't 100% accurate, TCP is fine for some mmos , its far less suited for an mmo like planetside than it is for an mmo like aoc or wow. (DaoC uses both UDP and TCP btw)One other option that hasn't been mentioned yet is to just run with something like RakNet which simplifies alot of things and also allows you to easily send reliable and ordered packets over UDP.I'd strongly agree with that statement. There is no "right" answer to the question, which is why I didn't give a definitive one. I think for someone who is beginning, TCP is a lot easier to grasp and work with. Libraries like Raknet are also quite useful and do a lot of the work for you.In many cases they hit a nice balance between UDP and TCP (usually by emulating TCP-like behaviour on top of UDP when you require it).Naturally, writing your own system specifically for your game is always going to be better but it takes a lot of time and expertise.   