Question about UDP

Started by
2 comments, last by hplus0603 17 years ago
Hello everyone! Okay, so I have a first-step game here. You walk around and the other clients can see you. That's it. On a 2GHz computer, one server and 2 clients run perfectly fine. On a (very crowded) 1.4GHz, not so much. The opposite clients move very slowly on the screen. I can't use both computers due to a temporary (I hope) router problem. I'm using TCP right now. Maybe UDP will do it better? It's unreliable though. When clients first connect, data that cannot be changed it sent, such as user ID and total number of players. I'm working this way; client presses a key, sends new X/Y to the server, server sends X/Y to the other clients. Wouldn't it look choppy if some of the X/Y's don't get to their destination? What if they're corrupt, it would be worse. Can someone please clarify? Thanks in advance! (PS: If you need to know, the language is the lovely C#)
Advertisement
Corruption is unusual enough not to be a problem. Choppiness can be avoided by buffering some input from the server and interpolating between two previously received positions; but this creates some percieved latency (lag). For two clients TCP or UDP shouldn't matter; are you disabling nagles algorithm (m_socket.NoDelay = true)?
If you want to try UDP i'll shamelessly plug my own library at http://code.google.com/p/lidgren-library-network
UDP guarantees that packets will arrive intact. They might arrive out of order, not at all or multiple times, but if a packet arrives, you can assume it's valid.
The non-corruption guarantee of UDP is unfortunately based on a very weak checksumming algorithm. However, if you do authentication through cryptographic signing (hashing), then that will take care of detecting corruption for you.

[Edited by - hplus0603 on April 23, 2007 10:23:49 AM]
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement