Quote:
Originally Posted by SteveRambo
... you might as well just use UDP then, if you don't care in what order your packets are processed :o
|
TCP have packet-ordering. It doesn't mean that 100% of the trafic must be processed in order...
Quote:
Originally Posted by SteveRambo
Player jumps from position 300, 300 to 300, 310 and sends packet A to the server with this information.
Player jumps from position 300, 310 to 300, 320 and sends packet B to the server with this information.
The server receives packet A and B in the correct order, because the server uses TCP.
The server uses a thread pool to process packets, so both packet A and B are submitted to the thread pool for processing.
The server uses thread A for processing packet A and thread B for processing packet B.
While processing packet A in thread A, the operating system suddenly decides to stop thread A before it's done processing and gives thread B time to run.
Thread B happens to complete the processing of packet B and now the operating system gives time for thread A to continue again.
What happens then? The client is going to get disconnected because the server processed the packets in the wrong order: it thinks that the player jumped from 300, 300 to 300, 320 (distance = 20 ==> disconnect).
|
And the only solution is to have a single-thread system ?
Single-threaded design for a MMO is a really, really bad design. You could at least have worker threads and a player on one worker. Meaning, your issue is no longer an issue. You could also have worker threads with queued mouvement packets, and other worker threads for packets who can be handled out-of-order ? You could do whatever design you want to achieve the synchronisation you want. If you're good enough, you could also design a distributed architecture.
====
Honestly, anyone thinking having a single-threaded design is the way to do for a MMO should stop making one, or expect a very small player-base.