UDP vs TCP

Posted by HomerTheDragoon on Dec. 4, 2006, 5:54 p.m.

<b>39.dll:</b>

Alright for my project im working on, its the first time ive used 39.dll. And I was reading up on it alittle(i already got my lobby(waiting room, it shows players in the game ie name) However i was wondering if i should use udp on both sides or no. Because from what i read, if you dont make a udp port on the client side they dont need to worry about port forwarding. Anyways, as most of you know, or i think that udp sends information faster.(however not everything is gaurenteed…) Anyways What should i do? How much of a difference will it make?

<b>BMG:</b>

Hopefully this will be intergrated to online soon so you can duke it out with other people in some zanny minigames online!. Once i finish the online engine ill merge it with the game and hopefully it will become one of the best online party games! eh maybnot but it will probably be a first for a gm game(first online minigames game).

The link to the game is in one of my blogs i think 2 ago.

Comments

Arcalyth 17 years, 11 months ago

UDP. TCP has too much overhead, and you will get horrible lag.

HomerTheDragoon 17 years, 11 months ago

hmm so i should require the player to open a port?

i suppose itl be worth it if it improves speed by alot.

Btw what is setnagel? what does it do.

SleepinJohnnyFish 17 years, 11 months ago

http://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci754347,00.html

Basically, it doesn't send the data until there is at least a minimum packet size fulfilled by the message. This can be very bad in some cases, and I would recommend that you not use it starting out, as if could seem as though your program is having an error when in reality you just haven't filled the buffer enough.

SleepinJohnnyFish 17 years, 11 months ago

Also, you can't base an entire game only using UDP, and you definitely don't want to. UDP should be used for messages that, if they do not arrive, will not screw up the game. Things like the player's position, for example. If the game has the wrong position of a character, it won't throw an error…. but what if the player picks up a flag in a CTF game…. if you use UDP, the message might never arrive, but then if the capture message does, then on your screen it will look like your flag was captured without ever being taken.

Use UDP for messages that need to get their quick, but don't actually NEED to get there. Use TCP for anything drastically important.

HomerTheDragoon 17 years, 11 months ago

Hey, thanks for explaining that too me. That helped alot, btw what does setnagel do?(its a script within the 39.dll script compilations.)

Evilish 17 years, 11 months ago

Considering their playing an online game, they should already know how to port forward.

Theres also another good thing about UDP, you can send/receive to someone without having to connect to them. (useful for pinging servers before connecting, getting their details, etc)

And hey! SJF answered what setnagel does

HomerTheDragoon 17 years, 11 months ago

hmm not sure if i should disable it or not…

SleepinJohnnyFish 17 years, 11 months ago

You should, for now. When you start understanding how different multiplayer systems work with the size of packets, then you'll understand when to turn it on. The speed difference when it is on is negligible, so don't worry abotu it. Just turn it off for now.

HomerTheDragoon 17 years, 11 months ago

alright thanks alot, Also is there an easy way to detect if someone left the game? ping? if so can u direct me in the right direction. Thanks for all your help so far.

SleepinJohnnyFish 17 years, 11 months ago

when you check receivemessage(conn) and it returns 0, that meanst he person is no longer connected.