I'm making a client/server, everything works grand its very simple, a simple login system, ID, empty variable and the X and Y positions of the player.

Should my server tell my client who it is? and if so what kind of relationship would a client/server usually have?

My server currently stores each connection so I can communicate with one, or all clients - is this the right type of architecture?

  • 1
    \$\begingroup\$ It's not clear what you mean. How do you have a login system without the client having any idea who it is? Why can't the server just tell the client? What actual problem are you running into, in detail? \$\endgroup\$ Commented Jan 13, 2015 at 4:58
  • \$\begingroup\$ Sorry for being vague, thought it would be. Basically my server knows who the client is but my client doesn't yet, I can tell my server to tell my client who it is and my question should have been - Should my server tell my client who it is? edit - this is client/server no peer 2 peer (just to clarify). After posting this I also googled, and found [link]gamedev.stackexchange.com/questions/552/… \$\endgroup\$
    – Mattg123
    Commented Jan 13, 2015 at 5:08
  • 2
    \$\begingroup\$ update the question to clarify it. :) \$\endgroup\$ Commented Jan 13, 2015 at 5:12

1 Answer 1


The question is rather unclear. How exactly the client should manage info about who he is, if that is just to display on players screen "I'm Mike" or to send out commands "I'm Mike, moving knight from c5 to e6" ?

When client connects to a server, it says who he is during login. Then both client and server have that info. Since servers can't trust clients, the server must manage list of clients and know which one is which when sending out packets/messages.

Servers can't trust clients, to disallow kind of cheats, when client named Jack sends a message "I'm Mike, moving knight from c5 to e6", hijacking the game.

Some game messages are addressed and others are broadcast to all. Being able to send messages via server to a single client, to a set of clients or to all at once is a right kind of design.

  • \$\begingroup\$ Yeah sorry, I'm a noob and that was my first question. So, the client knows nothing about any other client and when necessary the server will tell clients about what the other clients are doing \$\endgroup\$
    – Mattg123
    Commented Jan 13, 2015 at 5:56
  • \$\begingroup\$ Of course client needs to know about other clients, so he is aware and can address messages with them. Mike needs to know about Jack and be able to send messages addressed to him. But the server needs to verify that kind of message is allowed and does not break the game rules. Without knowing genre, it's hard to tell more, cos different game genres impose different network solutions. \$\endgroup\$
    – Kromster
    Commented Jan 13, 2015 at 6:11
  • \$\begingroup\$ The genre is just a really simple RPG, you can log in walk around and I plan to add the ability to type messages. As far as clients knowing each other, my server handles all connections and stores an ID for each connection, the client is then given that ID, to communicate with other clients it sends the ID back to the server with a message to do something, currently just to walk around. So clients have no direct contact with each other, and the server acts as a relay. Is this the correct way of implementing a client/server? \$\endgroup\$
    – Mattg123
    Commented Jan 13, 2015 at 10:11
  • \$\begingroup\$ Sounds about right in general. We use that scheme to avoid firewall issues, cos often clients can't talk to each other directly because of that. \$\endgroup\$
    – Kromster
    Commented Jan 13, 2015 at 11:16
  • \$\begingroup\$ To add to this, there's no actual rule against clients talking to each other directly; just don't let them do whatever they want. If I send StartedCasting to the server and to you, directly, it gives the server what it needs to verify hits, but only tells your computer which animation to play for me. I could make other clients play the wrong animations, but it doesn't allow me to cheat or kill you unfairly. To hurt you, my spell has to completely finish casting, travel and hit you, and the hit validated by the server. \$\endgroup\$
    – Jon
    Commented Feb 9, 2016 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .