Skip to main content
Share Your Experience: Take the 2024 Developer Survey
125 votes
Accepted

Is UDP still better than TCP for data-heavy realtime games?

No, UDP is still superior in terms of performance latency, and will always be faster, because of the philosophy of the 2 protocols - assuming your communication data was designed with UDP or any other ...
Peter's user avatar
  • 9,925
32 votes
Accepted

Acknowledgement reliability using UDP

This is a form of the Two Generals Problem, and you're right - no number of retries is enough to perfectly guarantee receipt. In practice in games, there's usually a time horizon beyond which the ...
DMGregory's user avatar
  • 135k
19 votes

Is UDP still better than TCP for data-heavy realtime games?

We agree upon both TCP and UDP being protocols built on top of IP, don't we? IP specifies how messages are delivered across the internet, but nothing is about the messages structure, format. Here come ...
liggiorgio's user avatar
  • 4,831
9 votes

Is UDP still better than TCP for data-heavy realtime games?

TCP <- Transmission Control Protocol. It's made to control transmission. TCP was created to be a good and diplomatic network citizen. It focuses on making the networking a good experience for ...
Stormwind's user avatar
  • 1,063
9 votes
Accepted

Does it make sense to use both TCP and UDP at once?

It results in packet loss for UDP due to contention between the two protocols - remember that UDP is not guaranteed delivery, while TCP is. More TCP packets will get through while UDP suffers - TCP ...
Engineer's user avatar
  • 29.9k
9 votes

Acknowledgement reliability using UDP

The approach TCP uses is that the sender will keep resending the packet until it receives an acknowledgement. The receiver will ignore duplicate packets, but still send acknowledgements for them. The ...
Quitting Due To Antisemitism's user avatar
7 votes

Acknowledgement reliability using UDP

If you want to reinvent TCP, it makes sense to look at TCP first, which deals with the exact problem you describe (part of the solution is to use user defined values for retry attempts and timeouts). ...
Peter's user avatar
  • 9,925
6 votes
Accepted

Network protocol for chat -- UDP or TCP

When it comes to chat systems, reliability is far more important than latency and bandwidth. That would usually make it a typical TCP/IP use-case. However, using both TCP and UDP in parallel through ...
Philipp's user avatar
  • 120k
5 votes
Accepted

How to organize messages queue in a fast-paced multiplayer game

You should implement your UDP reliable as TCP. On http://gafferongames.com/ you can read about packing packets, resending them, correcting errors. There is some pseudo-code (or this is written in C, ...
Jacob's user avatar
  • 2,552
5 votes

Does it make sense to use both TCP and UDP at once?

Here's a quote by Sam Jansen from a comment on gafferongames.com: Speaking as a network researcher and not a game developer, the conclusion to never use TCP and UDP together seems a bit strong. TCP ...
Pubby's user avatar
  • 699
4 votes
Accepted

How to properly handle sending arrow-key movement data to a authoritative server?

If you're using UDP then, as you say, you don't get reliability from your transport layer, so you'll need to build it into your game layer instead. In addition to the TCP style of detecting a missed ...
DMGregory's user avatar
  • 135k
4 votes
Accepted

Why can I only connect one client to my server?

Update These are the lessons learned from fixing this problem: We found the following issues when reviewing the network code: [Client/Server] UdpClient.Receive ...
Theraot's user avatar
  • 27k
3 votes
Accepted

What is a reasonable bandwidth usage for a RT multiplayer game?

From this article, I would say 100MByte/hour is a reasonable estimate for the popular multiplayer games out there: https://www.rhoonet.com/how-much-data-does-online-gaming-use 100MByte/hour converts ...
Jon Snow's user avatar
3 votes

Acknowledgement reliability using UDP

In an RTS you really cannot use a protocol like TCP, and you cannot make UDP reliable either. If you try to, the game will freeze whenever a there is a network hick-up. Instead, you design the ...
Stig Hemmer's user avatar
3 votes
Accepted

Synchronizing over UDP

When the user presses the button to enter panic mode, generate a sequential ID to tie to that event of wanting to enter panic mode. You then periodically send a message to the robot "Activate Panic ...
Alan Wolfe's user avatar
  • 2,353
3 votes

Does it make sense to use both TCP and UDP at once?

Is this a reasonable idea? Yes What are the possible drawbacks? Packet Loss, more code complexity, another connection to manage == more chance for disconnects, time outs, exceptions, whatever ... ...
Shmoopy's user avatar
  • 69
3 votes

Is UDP still better than TCP for data-heavy realtime games?

You may compare the first diagram of RFC 768 (UDP) to the first diagram of RFCP 793 (TCP) page 15. Both show 16 bits for a “source port” followed by 16 bits for a “destination port&...
TOOGAM's user avatar
  • 131
2 votes

Is UDP still better than TCP for data-heavy realtime games?

I know that UDP is usually recommended for real-time multiplayer games with high data usage Is UDP still superior in terms of speed and latency? Could recent TCP optimizations have made TCP perform ...
Damon's user avatar
  • 1,384
2 votes

Is UDP still better than TCP for data-heavy realtime games?

In a high bandwidth MPG, you don't care if you missed a packet giving you the location and health of monster #425, because you'll be getting another update in some fraction of a second. This is and ...
dusc2don's user avatar
2 votes

Is UDP still better than TCP for data-heavy realtime games?

Consider what's happening for a moment. To simplify the scenarios, you have two choices when trying to send a state change (like your player just changed direction, or shot a gun, or some other player ...
Jeff Meden's user avatar
2 votes
Accepted

RTS game: How to handle disconnects in a fully connected peer to peer architecture?

First of all you need a way of detecting such issues and separate them from simple packet loss. Once you know you really have this happening and really need to work around this, there are several ...
Kromster's user avatar
  • 10.7k
2 votes

Will TCP really affects UDP if used in different context?

You need to always remember that UDP and TCP are both just protocols on top of the IP layer, which is packet-based like UDP. When you send data via UDP or TCP both will result in a number of IP ...
VaTTeRGeR's user avatar
  • 776
2 votes
Accepted

Should I create thread for both UDP and TCP?

30 threads on the server is no big deal... much less on a dedicated server. My PC has, at the moment of writing, around 1750 open threads (in Windows, you can find this in the task manager). Well, ...
Theraot's user avatar
  • 27k
2 votes
Accepted

TCP vs. Reliable UDP? Sending Reliable Packets in Fast-paced Multiplayer Games?

Running both TCP and UDP in parallel just leads to problems. Also, you might not need all the reliability features of TCP, so it might be overkill anyway. Most games solve this problem by replicating ...
Philipp's user avatar
  • 120k
2 votes
Accepted

Sandbox game: TCP or UDP

I know that UDP and TCP are not to be used at the same time, so I should only use one. Lies. You are not going to use them both on the same socket. Just like you are not going to use two ports on the ...
Theraot's user avatar
  • 27k
1 vote

Network limitation in multiplayer game

Your problem reminds me of this article about AoE: https://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php The articles solution for AoE's large number of units on screen is ...
Connor Hollis's user avatar
1 vote

udp over cellular networks?

TL;DR: There is no guarantee of performance, latency, or working at all whatsoever. Video streaming works with either UDP and TCP so a cell phone being able to stream video is no guarantee that UDP ...
Stephane Hockenhull's user avatar
1 vote

Synchronizing over UDP

A common solution I use to send safe messages over UDP is the following : When the state is changed on one side, send the message periodically (the more important, the shorter the period) until the ...
An intern has no name's user avatar
1 vote
Accepted

Handling Player "sessions" on a UDP based server

It's fairly simple. Timeout Make each client ping the server every few seconds. If the server haven't received any packets from the client for say 15 seconds, consider it at timeout. But by default ...
KaareZ's user avatar
  • 1,943
1 vote

Sending Vector3 from Unity to custom C# server

You cannot just send a Vector3 over the network, the data has to be serialized first. Either you are going to serialize it manually, or you use some sort of helper libraries that obfuscate all the ...
jgallant's user avatar
  • 8,424

Only top scored, non community-wiki answers of a minimum length are eligible