[MUD-Dev] How many UDP sockets to use?
Jon Mayo
jmayo at rm-f.net
Thu Nov 18 01:22:33 CET 2004
PizaZ wrote:
> "How many UDP sockets should I use in my MMOG?"
I would recommend one UDP socket for all real-time data. tag each
packet with what kind of real-time data it is.
The server would use a "well known" UDP port. the clients would be
free to use whatever port they want. replies to a client go to the
same port that it was sent out on. (reply to the source
address). This seems to be the most firewall-friendly way to deal
with UDP. Compare quake2 to quake1 protocol (not quakeworld) if you
want to see a good versus bad example of UDP.
For non real-time data I highly recommend you do one TCP socket per
player. Things like chat must be delivered. Important actions that
must be delivered should go over TCP as well. And if timing is
fairly important, tag the TCP packet with a frame number. For
example, if you use an item, that "use item" action must be
delivered. Rather than trying to implement a resend protocol over
UDP, you can tag your TCP-based message with a synchronized
timestamp. (this can be as simple as 1+last_server_update_number).
If you're worried about the overhead of lots of TCP sockets versus a
few UDP sockets where you implement your own resend system, don't
be. The overhead of implementing your own TCP-like protocol with
real-time features is more work and generally does not work as well
as TCP.
The C10K Problem webpage talks about solutions to efficiently handle
many (10,000-100,000) connections. http://www.kegel.com/c10k.html
If you are only going to have 500 sockets, it's a
no-brainer. select() or poll() is the way to
go. http://www.gamedev.net/reference/list.asp?categoryid=30 should
have a few good articles on this. There are many sites on the quake2
protocol, which would give you some good ideas on what sorts of
things you could do with your protocol.
Personally I want to write a game that would work over GNUnet (a
generic peer-to-peer protocol system). One could make some very
interesting distributed worlds, and the anti-cheating systems
required to make it to work would be quite an interesting
discussion! http://www.ovmj.org/GNUnet/
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list