Thread: Network programming theory

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    2

    Question Network programming theory

    Hi!

    1. I've been working on an OpenGL-based action game, and I've just arrived to the network part.
    Initially this is what i've planned: I'm using one server, x clients, and the server is looping through a list of the clients (and the server itself if its not dedicated). The problem is that I don't know exactly what they will send to each other.
    If the clients send wich units (players, AI, powerups, firing bullets, everything) they're moving, creating or destroying, what should the server answer? Either it's just sending back the time since last time it listened to the client and let it calculate everything, or should it calculate the changes made itself and send back the whole result? If the latter, the latency can become huge on bigger maps, but I guess it will be a lot safer.

    2. One more question: Should I use WinSock?

    Thanks,
    /KJ

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Read the intro thread, and discover the "beej" tutorial.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    39
    2 Things.

    1 - If its an action game you are going to want to use UDP rather than TCP (read the guide
    Salem suggested)

    2 - No, you shouldn’t use WinSock if you want your game to be 100% portable.*

    *That being said it’s basically the same implementation as Berkeley sockets which is on most systems so porting your game isn’t to hard and every Windows system has some version of WinSocks so you wont need to distribute extra libraries.
    So yes I would recommend using it.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2
    Thanks, I checked up those tutorials, but I didn't really find what I was looking for. The problem is that I don't know what the server will send to the clients.
    Either the server recieves changes from every client, calculate (if a player has moved, if a bullet is proceeding in its direction) and send it to everyone, or if the server just send back the changes from all the other clients. I believe that sending every new situation will take to long time but incremental updates sounds unsafe to me.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    That's your protocol design decision. Familiarize yourself with network programming, read some books, read articles on the web. Browse the Game Programming Gems series for articles about networking. GPG3 is the first of the series to contain a network & multiplayer section, and all subsequent ones (4, 5 & 6) do, too. And so on.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. image analysis theory: mapping a network
    By elninio in forum C++ Programming
    Replies: 5
    Last Post: 10-30-2008, 01:23 PM
  2. 3D Network Analysis Tool
    By durban in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 11-08-2005, 06:33 PM
  3. Need help with easy Network setup
    By the dead tree in forum Tech Board
    Replies: 9
    Last Post: 04-08-2005, 07:44 PM
  4. network problems
    By lucy in forum Tech Board
    Replies: 6
    Last Post: 01-01-2003, 03:33 PM
  5. WinXP Network Connections pop-up
    By DavidP in forum Tech Board
    Replies: 1
    Last Post: 10-02-2002, 05:36 PM