how to do an Multiplayer-Game?

hi guys…
i want to know how i can create games using tcp/ip in this points:

  • creating server/client
  • sending/recieving data (like x,y,z position)
  • close the socket

have anybody some good code or tutorials (which is done using with opengl apps) ?

thanks!
--------------------- www.mofux.de.vu

Multiplayer Game Programming (good book so i hear)

this is rather platform dependant, so nobody is going to be able to give you a good answer without knowing what os you use. also, this isnt really related to openGL, so you would probably have better luck at one of the many general game development websites.

Yes, this isn’t really related to openGL. I think to send/receive data of, say, xyz of a point, in a 3D game is basically the same thing like to send/receive text in a chat program. Actually I’ve done my Pool3D game by this means. You may look into some simple net chat programs and find out the usage of serversocket and clientsocket, or something like that, and then try to use them in your game.

hey, i know how to do this in theory… but not in praxis…
does anybody has got some good code for me?
I searched on the net but i diddnt find really good things ;(

so thanks guys!

Hi,
Multiplayer code is not as simple as asking , “how do I do multiplayer games”. There in fact two questions at issue here.

  1. How do I connect two(or more machines)? If you mean PC’s then DirectX has protocols for these. They are not perfect, but I recomend them to beginers.
  2. How do I write a multiplayer game?
    This is a much more more complex issue. To begin with you must decide what model you wish to use. The two most common are.
    a) Peer-to-peer, meaning each machine does it’s own thing, and sends it’s state to everyone else. If the interaction between players is low, and controllable, this is a good model.
    b) Client-server, (like Quake, etc.) this is easier to impliment, and better for overall scalablity, but requires that specific code be writen (e.g. Server code).
    Probably most important though is that you recognise that you see multiplayer code in the same way as you you view structured code. It is not something you add at the end, but is something that you do, or do not. For good solid multiplayer games, you require that you seprate the game state, from EVERYTHING machine dependent. E.G. Cameras, sound, rendering, etc. In addition, all game state, must be driven by data “packets”. e.g. you must not use function calls or shared variables. Instead the game must run entirely from a single entry point (function) which is driven by messges. (the Windows message queue is prime of example of such a system). This allows is simple system be used to send the state to one or more machines, e.g. system 1.
    Just as OpenGL allows a unified arcitecture for graphics, you must define an OpenGL style system for your game. Allowing you try different implementations for the underlying code.

Anyway I’m rambling now, but the point is you must refine your question, and change your thinking. I do not know of any books which address games specifically, but if you are looking for more info, then try reading about the OSI (ISO) model of neworking. For practical examples, try www.gamasutra.com, this is a very good site for all games related resources.

Nigel