Jump to content
  • Advertisement
Sign in to follow this  
jbrowne

basic game server design

This topic is 3879 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 am curious as to what a basic game server looks like. What I have now is a server with a 'master' socket that creates a new socket for the client when they try to connect. I want this new socket to send server data to the client constantly and still be able to receive data from the client when it finds data to be received. Is this possible, or should there be two sockets for a single client? Right now I cant seem to figure out how to do this. Also, feel free to offer up game server designs that would be more efficient if this one is flawed. Right now I am just thinking in pretty basic terms here so I can get an idea for how one begins to start a project like this. Thanks in advance for replies. :)

Share this post


Link to post
Share on other sites
Advertisement
First, read up on basics of UDP and TCP (or IP in general) networking. Next, learn how to use basic sockets. Forum FAQ offers some pointers, googling for "socket tutorial" should also help a bit.

Then write a chat client/server or something similar that passes data back and forth. It should clear things a bit.

Game server design is quite far down that line.

Share this post


Link to post
Share on other sites
well i already have a client to client style chat program and a chat server that will send the data it receives to all the connected clients. the problem is that this chat server only responds to things being sent to it. what i want is for it to be constantly doing this in the background and have it receive client data at the same time that will alter the response.

i want to do this without threading and with only one socket per client so i am just wondering if that is possible. I am using python btw.

Share this post


Link to post
Share on other sites
Sockets (TCP and UDP ones, although a UDP socket is more of a convenience of thought than a 'real' thing I think) are bidirectional, so you should only have one to each client. Your server application can send things down the socket to a client whenever it likes; if you want the server to run things 'on its own' I recommend having a timer that triggers server actions.

The Abaria server does it this way: when a client sends a message, it can result in changes to the game world, which get sent to everyone who is interested. In addition, it has a timer that is run once a second, which updates a frame counter, and actions with various time periods are run from the timer. Those actions can cause messages to be sent to clients (in fact I send the frame counter every second to everyone).

Share this post


Link to post
Share on other sites
Ahh thanks. I have created a timer that works well. My next question is: does it make sense to have a database that holds the server data for a real-time game server? Is there an easier way for all the sockets to be able to access the same data?

Share this post


Link to post
Share on other sites
A database is for holding durable data.
An in-memory representation is for holding transient, shared data.
All the sockets will live in the same address space; do not use fork() for a game server.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!