Asked • 03/27/19

Handling incoming packets immediately or queuing them?

I'm using Golang to write a game server. I was wondering what the advantages of queuing the incoming packets for processing over processing them immediately. For example (processing immediately) each new connection/client a new goroutine/coroutine is created and within that goroutine a loop that reads from the network socket and has a switch statement that routes and handles each packet. Or (queuing) each new connection/client a new goroutine is created and within that goroutine a loop that reads from the network socket and passes it to a queue. A second dedicated goroutine for this connection/client has a loop that process the packets in the queue. Is this a pre-optimization? How are MMORPG's (server side) packet recv/handling handled in principle? I'm using TCP.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.