Sign in to follow this  

Client-Server connection

This topic is 3663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm very new to this Network Programming and just wanting to get involved a little bit by asking a (more than likly stupid) question. In looking about at tutorials for programming with WinSock there was an example that used an exe acting as a server and then an exe that acted as the client. When looking at the code for the server it was very much designed for the client, is this normal? or could i make a more general purpose simple server that can be used for many different games? Is the first way more efficient? As i said i am VERY new to this so any feedback would be nice (go easy on me) Thank you

Share this post


Link to post
Share on other sites
The server has to be able to cope with anything the client sends it. You can't really make a general purpose server for any game, but you could make a server that would be general purpose for all of your games.

If you make all your games use a message/packet based system, all you need to do is give each message a unique ID, and make sure that two games IDs don't overlap. That's easier said than done, unfortunately.


Generally though, you write the server for just the one game.

Share this post


Link to post
Share on other sites
Thank you very much, I think I will just stick to making the server for each game then, in an effort to not over complicate things.
I'll make sure I learn more about network programming as I develop games for fun.

Share this post


Link to post
Share on other sites
It helps to make a plan before you start. Make yourself a text file and start filling it with all the network commands you think your game might need, and start assigning them ID's.

It really helps, I've started planning like this before I do anything these days, I'm currently just finishing a custom 3D model file format, and without a big text file of planning it would have been a nightmare.

Plus, you'll be able to figure out beforehand how many digits the maximum ID is, I.E., if you came up with 130 commands, you need three characters sent for the ID, which allows you up to 999 commands just in case. If you only come up with 20, use two characters, that gives you 99 to play with.

Share this post


Link to post
Share on other sites
I am a bit of a bugger when it comes to planning, i tend to jump in feet first, not the best way to go about things ^_^ but i am starting to plan things more often now. That sounds like a really good idea though so i will take that on board definatly, Thank you deadstar.

Share this post


Link to post
Share on other sites
Quote:
Original post by deadstar
I.E., if you came up with 130 commands, you need three characters sent for the ID, which allows you up to 999 commands just in case. If you only come up with 20, use two characters, that gives you 99 to play with.


Or just use a single byte which can store up to 256 unique id's...

Share this post


Link to post
Share on other sites
Quote:
Original post by deadstar
Plus, you'll be able to figure out beforehand how many digits the maximum ID is, I.E., if you came up with 130 commands, you need three characters sent for the ID, which allows you up to 999 commands just in case. If you only come up with 20, use two characters, that gives you 99 to play with.

omg no! Thinking of things as strings is inefficient and less flexible than the "real" way of using the binary data. If the data is in binary why turn it into strings? It's completely illogical.
http://gpwiki.org/index.php/Binary_Packet

What do you do when you need to send 100 floating point numbers?

Share this post


Link to post
Share on other sites
A game server that's a "general" game server is the MIX server from http://www.synthetic-reality.com/. You might want to look at that for inspiration. The main draw-back is that, if a server doesn't know about specifics about a game, it can't enforce the specific rules of that game, and thus it opens itself up to client cheating.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sirisian
Quote:
Original post by deadstar
Plus, you'll be able to figure out beforehand how many digits the maximum ID is, I.E., if you came up with 130 commands, you need three characters sent for the ID, which allows you up to 999 commands just in case. If you only come up with 20, use two characters, that gives you 99 to play with.

omg no! Thinking of things as strings is inefficient and less flexible than the "real" way of using the binary data. If the data is in binary why turn it into strings? It's completely illogical.
http://gpwiki.org/index.php/Binary_Packet

What do you do when you need to send 100 floating point numbers?


Seems I've used the incorrect terminology, that's not what I meant.

It's been a long morning :P

Share this post


Link to post
Share on other sites

This topic is 3663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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