Advertisement

TCP vs UDP vs TCP & UDP?

Started by July 26, 2002 11:04 PM
31 comments, last by hello2k1 22 years, 5 months ago
Stick to TCP because it is more reliable and more universal.

Developer Tutorials
quote:
Original post by Tilch
Stick to TCP because it is more reliable and more universal.



More universal? What do you mean by that ?



[edited by - granat on August 9, 2002 3:45:29 AM]
-------------Ban KalvinB !
Advertisement
TCP is the "easy" way to do it and is generally a good way to get a game going since it eliminates most issues with network coding without you doing anything. e.g. Your project will work. If you want to make it work better THEN introduce the added complexity of UDP and even then you''re not guarenteed it will actually be better.

With UDP you could just end up reinventing TCP (and a slower less efficient version at that) and in the process waste a significant amount of time that could have been better spent developing game play and optimizing your messaging system.

For my MMO project, I''m using and sticking with TCP because UDP would be a giant waste of my time. I may learn it later but I have more important things to work on at this time.

Without specific details on your project there''s no telling which would be better. If you wrote a UDP wrapper and a TCP wrapper it would be a trivial task to swap them in and out of specific tasks to see which one works better.

Personally, I always go with TCP (or in DPlay''s case; Guarenteed messages) until I know my project works. Speed is irrelavent until you have it working. If you worry about UDP now, when something doesn''t work you''ve got a lot more variables to contend with.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Dot Com | GameShot ]
Ok, everyone seems to be saying the exact same thing.. I''m just going to finish this off. But, I do however have a question.

If I were to use UDP, would the users have to forward the game port(s) if they had a router? I don''t want the users to have to mess with anything like that, so any measures to counter having to make the users do such a thing would be useful.

Thanks for all your help.
------------------------------There are 10 types of people in this world, those who know binary, and those who don't.
Do you mean the port that they (clients) are sending their data through? If so, that info is returned in the sockaddr struct when you call recvfrom() (and if they are behind a NAT router, the port will be the port on the router, which will get relayed back to the client that originated the udp)
quote:
Original post by hello2k1
If I were to use UDP, would the users have to forward the game port(s) if they had a router?



If they host, yes. If they are only clients then no.

-------------Ban KalvinB !
Advertisement
quote:
Original post by granat
If they host, yes. If they are only clients then no.


Hmm. Why is that?


[edited by - hello2k1 on August 9, 2002 10:07:43 PM]
------------------------------There are 10 types of people in this world, those who know binary, and those who don't.
Because if they are client, the router "remembers" that the client sent a udp packet to x.x.x.x adrress at y port, and if it receives a udp packet from x.x.x.x address at y port, it will automatically assume that it is a reply to the udp packet that the client sent and so will automatically forward the packet to that client.
Oh, ok. So that means I''m free to explore both UDP and TCP without worrying about client side problems.

Thanks for all the help you guys!
------------------------------There are 10 types of people in this world, those who know binary, and those who don't.
quote:
Original post by hello2k1
Oh, ok. So that means I'm free to explore both UDP and TCP without worrying about client side problems.



Yes !

Actually I asked about this some time ago. If you want a more detailed explanation you could look at this old thread.

http://www.gamedev.net/community/forums/topic.asp?topic_id=67991


EDIT: Maybe not that detailed info but still worth a read..

[edited by - granat on August 10, 2002 1:29:22 PM]
-------------Ban KalvinB !

This topic is closed to new replies.

Advertisement