Web Analytics Made Easy -
StatCounter Problem: client-server communication - CodingForum


No announcement yet.

Problem: client-server communication

  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem: client-server communication

    I want to make a simple simulation of appliable client-server communication.

    Client: request to buy item
    Server: checks if item is available
    Server: if item is available server changes it's information(inventory), if not it sends a message to client that item is unavailable.
    Client: if success updates information(request updated data), if not displays an error code provided by the client in text form.

    My problem is that building a complex message protocol is tedious, I think it is possible but I doubt any real game designers use this method.

    Is there a way to simulate the above without sending strings or specific multi-byte codes(which would take even more time).

    This is not a school project, I am just building up ideas how I can make a good game. The problem above is the core of any game.

  • #2
    You'll probably get more help if you ask in the Multiplayer and Network Programming section of the forums on gamedev.net or similar sites.


    • #3
      Perhaps but I always believed that concepts do not depend on where you apply them.

      This is pretty much a chat server with enhanced data.


      • #4
        I'm really not sure what game designers use, but after studying networking my gut reaction is that they use UDP with their own specialized error checking that's quicker the TCP. The only bad thing is you don't get the promise that the packet will come in order, so this is something else you'll have to check. Or, you can stick with tcp, which will give you all that at a cost.

        As for what to send, this is where things get more interesting. If you're protocol is ONLY sending the price and then a yes or no answer, I'd say try and represent it in a binary form, that way the response can be an easy yes or no.

        If you plan to do more then that you really need to come up with some sort of message protocol. If your server is going to do anything else that's complicated then unfortunately that's the way to go.

        When building the protocol though try to make it as simple as possible without losing it's complexity. One way you can do this is to segment the byte ordering of the message you pass. So the first byte, or bytes can be the type of message you are sending. Price check, buy order, sell order, money transfer, etc. The next byte can be a secondary field like the item, and the third field can be the tritary field, like the price.

        Or something like that. It's hard to get specific without knowing what you are planning to do, but hopefully that'll give you some things to think about.

        Or that's just my opinion on the matter.
        "To iterate is human, to recurse divine." -L. Peter Deutsch


        • #5
          how should I check the messages? Thousands of if statements?

          And how can I make it so I can add new messages to the protocol?


          • #6
            Or a case statement. No matter what you're going to have to classify it in some way, and unfortionatly this isn't c++ so you have to do it in a more direct manner.
            "To iterate is human, to recurse divine." -L. Peter Deutsch


            • #7
              what do you mean 'direct' manor, c++ can do this more directly?