Sign in to follow this  
astrospider

FPS Game Server Tips

Recommended Posts

I shall create a game server for a own maded FPS game. (DirectX 9) I have only some experience in winsock and don't know if I shall use winsock or DirectPlay. At most the server will have about 128 connections at one time. I have done some reasearch about winsock/DirectPlay and winsock with IOCP and need some help about what to choose ;) I have figured out that IOCP is very good if u want to handle alot of connections and don't create 1 thread for each connection, but is it good to use IOCP in a FPS game server or is it only a waste of time? what shall I use, DirectPlay or winsock? what would u do use? TCP or UDP or maby mix them both? I have read alot of information about TCP/UDP with different games, but I don't really understand what's best to use in a FPS game... Does anyone have any good books or links that explain winsock or IOCP? I haven't found alot of books about this, so I would appreciate some tips about books ;) thanks alot in advance :)

Share this post


Link to post
Share on other sites
There is no issue with using UDP or TCP its just knowing when to use either.
You should use TCP (or your UDP equivalent) for things like log in, chat, log out, new map etc. And UDP for things that need to be fast, but you can afford to lose a few packets of like position updates.

Share this post


Link to post
Share on other sites
For UDP, you only have a single socket, so IOCP wouldn't be necessary.

DirectPlay is deprecated and won't be developed more by Microsoft; they recommend using Winsock. You can also use one of the libraries found in the Forum FAQ to help you out.

You don't necessarily have to use TCP for chat or login; you could also build everything on top of UDP without too much trouble. Many libraries (like Enet) give you reliable channels on top of UDP. This may simplify your code, too -- only a single socket needed for the entire server!

Share this post


Link to post
Share on other sites
depending on your data load, and the rate of your entities update (10~15fps), I think TCP would do the job perfect...I've read somewhere that CodUO is TCP only...


Tcp is simpler to manage

In the game we just did, we used to mix TCP with UDP ... the problem we had is that sometimes TCP lags and not UDP(very rare), resulting in a loss of synchronisation (invisible guys shooting)

We've put it back to TCP only, and now a home connection (Cable/DSL) can host an 8 player game... and theres a lot of projectiles in the game.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
DirectPlay is deprecated and won't be developed more by Microsoft; they recommend using Winsock. You can also use one of the libraries found in the Forum FAQ to help you out.

You don't necessarily have to use TCP for chat or login; you could also build everything on top of UDP without too much trouble. Many libraries (like Enet) give you reliable channels on top of UDP. This may simplify your code, too -- only a single socket needed for the entire server!


ahaa okey :)

so you would recommend me to use winsock with UDP instead of winsock with TCP for the whole game?
shall I care about threads or it's not necessary if I use UDP?
is it only necessary to use threads with TCP or with both?

thanks alot for yur previouse answare it have helped me :)

Share this post


Link to post
Share on other sites
Quote:
Original post by md_lasalle
We've put it back to TCP only, and now a home connection (Cable/DSL) can host an 8 player game... and theres a lot of projectiles in the game.


hm.. isn't there a mimit to 64 connections /socket? Or I have mixed it up? :P
because I shall have at most 128 connections that's why i'm asking ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by astrospider
Quote:
Original post by md_lasalle
We've put it back to TCP only, and now a home connection (Cable/DSL) can host an 8 player game... and theres a lot of projectiles in the game.


hm.. isn't there a mimit to 64 connections /socket? Or I have mixed it up? :P
because I shall have at most 128 connections that's why i'm asking ;)


For the select function the default is 64 but you can define FD_SETSIZE before including winsock to the required size.

Share this post


Link to post
Share on other sites
Quote:
so you would recommend me to use winsock with UDP


That's what I would do.

Quote:
threads


If I were doing a TCP server on Windows, I would use IOCP, with one thread per physical CPU. If I didn't do IOCP, I wouldn't bother with threads.

For UDP, you need a single socket only, so no threads needed. Also, with UDP, there is no connection limit, because YOU create the connection concept; typically using a hash table of the source UDP port (as seen in ::recvfrom()).

Share this post


Link to post
Share on other sites
Quote:

DirectPlay is deprecated and won't be developed more by Microsoft

True, looks like Windows Live is the next step down that track.

To OP,
You might like to take a look at RakNet it's a crossplatform networking library that supports all sorts of wicked things like autopatching and multicasting that should make your life a little easier.
It's also opensource and free for non-profit apps. If I remember correctly.

Share this post


Link to post
Share on other sites
Quote:
Original post by luke2
There is no issue with using UDP or TCP its just knowing when to use either.
You should use TCP (or your UDP equivalent) for things like log in, chat, log out, new map etc. And UDP for things that need to be fast, but you can afford to lose a few packets of like position updates.


Quake 3 uses UDP for everything. Everything. It's a very elegant solution.
I allways post this link in any TCP vs UDP debate, coz it gives a solution to the whole "unreliable vs reliable" and "out of order vs in order" debate.
http://trac.bookofhook.com/bookofhook/trac.cgi/wiki/Quake3Networking

Also, I reccomend using something like RakNet (someone link posted earlier) as they've allready done the low level work of taming the UDP protocol for games usage for you. Plus its open source if you want to change how they did something ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Lumino
Quote:

DirectPlay is deprecated and won't be developed more by Microsoft

True, looks like Windows Live is the next step down that track.

To OP,
You might like to take a look at RakNet it's a crossplatform networking library that supports all sorts of wicked things like autopatching and multicasting that should make your life a little easier.
It's also opensource and free for non-profit apps. If I remember correctly.


thanks alot for the tips ;) I shall take a look on RakNet

Share this post


Link to post
Share on other sites
Quote:
Original post by PhilMorton
Quake 3 uses UDP for everything. Everything. It's a very elegant solution.
I allways post this link in any TCP vs UDP debate, coz it gives a solution to the whole "unreliable vs reliable" and "out of order vs in order" debate.
http://trac.bookofhook.com/bookofhook/trac.cgi/wiki/Quake3Networking


thanks :), I shall take a look on the link, it will probably help me some ;) thanks alot!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this